Pin swag version in swagger-install task#5802
Draft
jerm-dro wants to merge 1 commit into
Draft
Conversation
The task installed swag via `go install .../swag@latest`, so `task docs` could silently pick up a newer swag release with different schema-name disambiguation behavior than the version pinned in go.mod, reintroducing drift across contributors' machines. Resolve the version already recorded in go.mod instead of `@latest`.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5802 +/- ##
==========================================
- Coverage 70.84% 70.77% -0.07%
==========================================
Files 685 685
Lines 69458 69458
==========================================
- Hits 49208 49162 -46
- Misses 16636 16699 +63
+ Partials 3614 3597 -17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jerm-dro
marked this pull request as draft
July 14, 2026 21:15
Contributor
Author
|
Converting to draft — this pins swag's version to close a real gap (unpinned |
10 tasks
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
task docs(via theswagger-installtask) installsswagwithgo install .../swag@latest, so every run resolves to whatever swag release is newest that day — independent of the version already pinned ingo.mod. If a future swag release changes internal schema-name disambiguation behavior (or anything else about generation), two contributors runningtask docson different days, or one contributor rebasing weeks later, can produce a divergentdocs/server/{docs.go,swagger.json,swagger.yaml}with no underlying API change, masquerading as a large, unrelated diff on their PR (as happened on Rate limiting observability (metrics and tracing) PR B #5800, which tripped the "Large PR Detected" gate).go.mod(go list -m github.com/swaggo/swag/v2) instead of@latest, soswagger-installalways builds the same generator that the rest of the module graph is pinned to.Investigation notes (for reviewers)
While root-causing #5800's diff, I confirmed a few things worth recording here so this isn't re-litigated later:
encoding/json.Marshalsortsmap[string]...keys alphabetically, and swag's YAML output goes throughsigs.k8s.io/yaml(gopkg.in/yaml.v2), which also sorts map keys. Five to six consecutive freshswag initruns against identical source (same machine, same swag binary) produced byte-identical output every time. A "canonically sort JSON/YAML output" post-processing step, as one might first assume is needed, would be a no-op today, so I didn't add one.Config/RunConfig, plus aregistrypackage name collision betweenpkg/registry,toolhive-core/registry/types, andoras.land/oras-go/v2/registry). Swag'sv2.0.0-rc5disambiguates these by qualifying colliding names with a sanitized full import path, decided while walking an unorderedmap[*ast.File]*AstFileInfo— this is upstream swag internals, not something we control from this repo. Within one stable environment (fixed swag version + fixedgo.sum), this comes out fully deterministic (verified with repeated reruns, and acrossGOOS=linuxvs. native macOS — identical). The divergence in Rate limiting observability (metrics and tracing) PR B #5800's committed file appears tied to some other difference in the authoring environment (e.g., module cache state) at generation time rather than plain map-iteration randomness, and I couldn't fully pin it down beyond that.@latest) rather than chasing further into swag internals. If drift is observed again after this fix, the strongest follow-up would be a CI job that regeneratesdocs/serverand fails the build on any diff — that's a separate change and not included here.Type of change
Test plan
Ran
task swagger-installand confirmed it now installs the version pinned ingo.mod(v2.0.0-rc5) rather than whatever@latestresolves to. Rantask docsthree times in a row and diffeddocs/server/between runs — byte-identical every time, and no diff against the currently-committed docs on this branch.Special notes for reviewers
The deeper schema-naming sensitivity described above is a known swag limitation, not something this PR attempts to fix — see the investigation notes for what's understood about it and why a CI verification job is the recommended fast-follow if it recurs.
Generated with Claude Code