Repository navigation
fix(index): report why an external reference could not be resolved - #724
Draft
daveshanley wants to merge 1 commit into
Draft
daveshanley wants to merge 1 commit into
daveshanley wants to merge 1 commit into
Conversation
When the rolodex could not open the document behind an external $ref, the failure was only logged. The reference error then claimed the component did not exist in the specification, dropping both the document location and the cause, such as a 404 from a remote server. The open failure is now kept per document location and wrapped into the reference error, so a broken remote reference reads: component `#/components/securitySchemes/X` cannot be resolved: unable to fetch remote document 'https://example.com/api/openapi.json' (error 404 Not Found) References to components that are simply absent keep the original message. Remote fetch errors also carry the HTTP status text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #724 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 315 315
Lines 39919 39927 +8
=========================================
+ Hits 39919 39927 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When the rolodex can't open the document behind an external
$ref(a 404, a timeout, a local path with no file system), the failure was only logged. The reference error then said the component does not exist in the specification. That's misleading, and it dropped both the document location and the actual cause.Before:
After:
How
lookupRolodexkeeps the open failure for each document location (refOpenErrors, async.Mapon the index, cleared with the other reference errors).missingComponentErrorwraps that cause into the reference error with%w, soerrors.Is/errors.Asstill reach the original error. A reference to a component that is simply absent keeps the existing message.RemoteFSfetch errors now include the HTTP status text:(error 404)becomes(error 404 Not Found).Message changes
Code that matches on error strings will see these changes:
component … cannot be resolved: <cause>instead of… does not exist in the specification.TestIssue578HttpPrefixedLocalRefDoesNotPanicnow gets the real cause in the error (remote URL 'httpdocs/pet.yaml' has no scheme, unable to fetch it), which it previously only checked in the log.TestNewRemoteFS_RemoteBaseURL_Error400now expects(error 400 Bad Request).Tests
index/missing_component_error_test.go: a local server that returns 404 for a remote$ref, and a missing local component that keeps the original message.go test ./...passes (35 packages).security-scheme-object-examplescases from the OpenAPI conformance suite instead of saying the component doesn't exist.🤖 Generated with Claude Code