Skip to content

Commit e2603bc

Browse files
committed
api: log non-ErrNoTOC failures in headingPathsForDoc (review)
GetTOC errors were all silently treated as 'no heading paths'. Now retrieval.ErrNoTOC (the expected missing-TOC case) stays silent while any other error is logged at debug for observability — still degrading gracefully. Per Sourcery review on #40.
1 parent efd783f commit e2603bc

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

internal/api/treewalk.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,18 @@ func (d Deps) headingPathsForDoc(ctx context.Context, t *tree.Tree) map[tree.Sec
388388
return nil
389389
}
390390
raw, err := d.TreeWalkStrategy.TOC.GetTOC(ctx, t.DocumentID)
391-
if err != nil || len(raw) == 0 {
391+
if err != nil {
392+
// retrieval.ErrNoTOC is the expected "no TOC persisted yet" signal —
393+
// silent. Any other error (DB/transport) is an operational issue worth
394+
// surfacing for diagnosis, even though we still degrade to no heading
395+
// paths rather than failing the request.
396+
if !errors.Is(err, retrieval.ErrNoTOC) {
397+
d.Logger.Debug("answer/treewalk: TOC fetch failed; citations omit heading paths",
398+
"err", err, "document_id", t.DocumentID)
399+
}
400+
return nil
401+
}
402+
if len(raw) == 0 {
392403
return nil
393404
}
394405
var nodes []tree.TOCNode

0 commit comments

Comments
 (0)