Skip to content

fix: use full git ref as URL path to avoid loader cache collision#802

Merged
reuvenharrison merged 1 commit intomainfrom
fix/git-revision-loader-cache
Mar 9, 2026
Merged

fix: use full git ref as URL path to avoid loader cache collision#802
reuvenharrison merged 1 commit intomainfrom
fix/git-revision-loader-cache

Conversation

@reuvenharrison
Copy link
Collaborator

Summary

  • When loading two git revisions of the same file (e.g. origin/main:openapi.yaml and HEAD:openapi.yaml) with a shared openapi3.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 empty changelog/diff output
  • Fix by using the full git ref (e.g. "origin/main:openapi.yaml") as the URL path, so each revision gets a unique key in visitedDocuments
  • Adds a regression test that loads two revisions of the same filename with a shared loader and asserts they contain distinct content

Test plan

  • go test ./load/... -run TestLoadInfo_TwoGitRevisionsSharedLoader passes
  • Reverting the fix causes the new test to fail (verified locally)
  • Full go test ./... passes

🤖 Generated with Claude Code

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]>
@reuvenharrison reuvenharrison merged commit 708b2db into main Mar 9, 2026
14 checks passed
@reuvenharrison reuvenharrison deleted the fix/git-revision-loader-cache branch March 9, 2026 21:53
@codecov-commenter
Copy link

codecov-commenter commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.57%. Comparing base (45e7dab) to head (ad9a291).
⚠️ Report is 2 commits behind head on main.

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              
Flag Coverage Δ
unittests 89.57% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@reuvenharrison reuvenharrison restored the fix/git-revision-loader-cache branch March 10, 2026 16:33
@reuvenharrison reuvenharrison deleted the fix/git-revision-loader-cache branch March 10, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants