Repository navigation
feat: add external reference inspection, export ErrExternalRefNotAllowed, and recover linter rule panics - #337
ThomasRooney wants to merge 2 commits into
Conversation
…wed, and recover linter rule panics
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…inter panic, and strengthen tests
There was a problem hiding this comment.
0 issues found across 4 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Adds a tested zero-I/O external-reference inspection API and exported sentinel, with linter panic recovery, YAML merge-key ref detection, and nil-guard fixes; all are bounded additive/bug-fix changes covered by tests.
View guided diff | Turn on auto-fix | Re-trigger cubic
Summary
references.ErrExternalRefNotAllowed(references/resolution.go): Replaces the inlineerrors.New("external reference not allowed")sentinel so callers usingResolveOptions.DisableExternalRefscan match the error viaerrors.Is.*openapi.OpenAPI(openapi/external_refs.go):FindExternalRefs(ctx) ([]ExternalReference, error)walks modeled OpenAPI referenceable nodes (Walk) without performing filesystem or network I/O and returns every$refwith a non-empty URI alongside a clonedLocationsslice. Respects context cancellation cleanly.ValidateNoExternalRefs(ctx) errorjoins errors wrappingreferences.ErrExternalRefNotAllowedfor each external reference found.openapi/core/reference.go): Expands<<merge keys viayml.ResolveMergeKeysbefore checking for$refso merged references on non-schema Reference Objects (e.g. responses, parameters, path items) are unmarshaled as references rather than inline objects.openapi/walk_tags_servers.go,jsonschema/oas3/walk.go): Avoid nil-pointer dereferences when walking programmatically constructed documents containing nilServerVariablemap values or zero-valueJSONSchemawrappers.linter/linter.go): Pre-captures the rule ID before launching each goroutine and converts any recovered panic into avalidation.Errorrather than terminating the caller process.Verification
mise cipassed locally (format check,go.modtidy across workspace modules,golangci-lintwith 0 issues,nilaway, examples check, unit tests with-race, CLI integration tests, and build).Summary by cubic
Adds zero-I/O external reference inspection for
OpenAPIdocuments and makes the linter recover from rule panics instead of crashing.New Features
OpenAPI.FindExternalRefs(ctx)walks all modeled references without filesystem or network I/O and returns external$refURIs with their locations.OpenAPI.ValidateNoExternalRefs(ctx)returns an error wrappingreferences.ErrExternalRefNotAllowed, with each reference's location in the error message.references.ErrExternalRefNotAllowedso callers can match it witherrors.Is.Bug Fixes
validation.Errorresults with stack traces rather than terminating the process.<<) are expanded before$refdetection on Reference Objects, so merged references unmarshal as references instead of inline objects.ServerVariablevalues or zero-valueJSONSchemawrappers in programmatically built documents.Written for commit 66ed455. Summary will update on new commits.