fix: use full git ref as URL path to avoid loader cache collision#802
Merged
reuvenharrison merged 1 commit intomainfrom Mar 9, 2026
Merged
fix: use full git ref as URL path to avoid loader cache collision#802reuvenharrison merged 1 commit intomainfrom
reuvenharrison merged 1 commit intomainfrom
Conversation
When loading two git revisions of the same file (e.g. origin/main:openapi.yaml and HEAD:openapi.yaml) with the same openapi3.Loader, the loader's visitedDocuments cache keyed both by the same URL "openapi.yaml", causing the second load to return the cached first spec. This produced empty changelog/diff output. Fix by using the full git ref as the URL path so each revision gets a unique cache key. As a bonus, relative $refs within a git-loaded spec now resolve to paths that isGitRevision recognises, enabling correct recursive git-revision loading. Add a regression test that loads two revisions of the same file with a shared loader and asserts they contain distinct content. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #802 +/- ##
==========================================
- Coverage 89.57% 89.57% -0.01%
==========================================
Files 239 239
Lines 12179 12178 -1
==========================================
- Hits 10909 10908 -1
Misses 840 840
Partials 430 430
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 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.
Summary
origin/main:openapi.yamlandHEAD:openapi.yaml) with a sharedopenapi3.Loader, both calls produced the same URL cache key ("openapi.yaml"), causing the loader to return the cached base spec for the revision — resulting in emptychangelog/diffoutput"origin/main:openapi.yaml") as the URL path, so each revision gets a unique key invisitedDocumentsTest plan
go test ./load/... -run TestLoadInfo_TwoGitRevisionsSharedLoaderpassesgo test ./...passes🤖 Generated with Claude Code