Skip to content

False positive circular-reference-invalid on external $ref schemas since v1.709.2 #1979

@SaranshChaudhary

Description

@SaranshChaudhary

Description

speakeasy lint openapi incorrectly reports non-terminating circular references when validating an OpenAPI 3.1 spec that uses external $refs to split schema files. The referenced schemas do not form any cycles.

Regression

  • Last passing: v1.709.1
  • First failing: v1.709.2 (commit 498f86a)

Error output

ERROR  validation error: [line 107:7] circular-reference-invalid - non-terminating circular reference
       detected: components/schemas/Product.json -> components/schemas/Product.json
ERROR  validation error: [line 120:7] circular-reference-invalid - non-terminating circular reference
       detected: components/schemas/Product.json -> components/schemas/Product.json
ERROR  validation error: [line 144:7] circular-reference-invalid - non-terminating circular reference
       detected: components/schemas/Product.json -> components/schemas/Product.json

Reproduction

The spec uses a split-file structure where a parent schema (Product.json) references child schemas via external $refs:

Product.json
  ├── pricing:      $ref: ./ProductPricing.json       (terminal — no further $refs)
  ├── promotion:    $ref: ./ProductPromotion.json      ($refs only promotion-type schemas, all terminal)
  ├── bundle_items: $ref: ./ProductBundleItem.json     ($refs Item.json → various terminal schemas)
  ├── variants:     $ref: ./Variant.json               (terminal)
  ├── images:       $ref: ./ProductImage.json           (terminal)
  └── attributes:   $ref: ./ProductAttribute.json       ($refs attribute-type schemas, all terminal)

A full graph traversal confirms no schema references back to Product.json. The Product.json -> Product.json cycle reported by the linter does not exist.

Command

speakeasy lint openapi --logLevel warn --non-interactive --schema catalog.json

where catalog.json is an OpenAPI 3.1 spec referencing schemas in ./components/schemas/ via external $refs like {"$ref": "./components/schemas/Product.json"}.

Expected behavior

Lint should pass (or warn), as there are no circular references in the $ref graph.

Environment

  • OS: macOS (darwin arm64)
  • Speakeasy CLI: fails on v1.709.2+, passes on v1.709.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions