Skip to content

openapi: the $dynamicAnchor index names its own walk bounds when the view's merge bound stopped it #454

Description

@fuad-daoud

dynamicAnchors (compilers/openapi/internal/schema/schema.go) reports whether the $dynamicAnchor index ran to completion as one bool:

return w.out, !w.truncated && !w.view.Exhausted()

AnchorIndex.sites then turns false into a single message:

the $dynamicAnchor index stopped at its walk bounds (512 levels, 1048576 nodes);
a $dynamicRef expanded below is not verified to name the document's only anchor of its name

But w.view.Exhausted() is set by a different bound: nodeview.MergeDepthLimit, the 64-level << merge-key expansion cap. A document whose merge chain is past that bound and whose walk never came near 512 levels or 2²⁰ nodes gets a warning naming two bounds it did not hit and omitting the one it did.

Reproducer

mergeBoundOrderSpec in compilers/openapi/internal/schema/schema_test.gox-d13..x-d20 carry chains past the merge bound. Since #453, both declaration orders emit the warning above; the walk itself is nowhere near its own bounds.

Before #453 the same message was reachable by any document that declared a deep chain before the shallow one it rides on, so the fold predates that change.

Suggested

Have dynamicAnchors report which bound stopped it — its own walk bounds or the view's merge bound — and have sites name that one. diag.CycleScanFailed already says "stopped at its 64-level merge-key expansion bound" for the pre-parse scan's identical case, so the message for that arm can match it.

Found while fixing #404.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions