Skip to content

Accept :tag as an alias for :ref when parsing git modules - #4

Merged
dploeger merged 2 commits into
dodevops:mainfrom
dennisboege-devoba:fix/puppetfile-tag-parameter
Nov 26, 2026
Merged

dploeger merged 2 commits into
dodevops:mainfrom
dennisboege-devoba:fix/puppetfile-tag-parameter

Conversation

@dennisboege-devoba

Copy link
Copy Markdown
Contributor

Problem

A Puppetfile line of the form mod 'x-y', :git => '...', :tag => 'v1' is valid r10k syntax. ModuleDeclaration.fromText() only looks for :ref in the parsed parameters, so :tag is silently dropped. this.ref stays undefined, fetchGitMetadata() skips the checkout step, and metadata.json is read from the repository's default branch. If the default branch carries different metadata than the tag, the resolver sees the wrong dependency ranges.

The user-facing symptom is confusing because the error message blames the Puppetfile module, not the parser. In our case the Puppetfile pins meltwater-cpan to a tag whose puppetlabs-stdlib range is >= 9.0.0 < 11.0.0, but the resolver was reading the master branch whose range is still >= 4.6.0 < 10.0.0. Combined with other modules that need stdlib 10, the resolve failed with:

Error: No possible version for requirement meltwater-cpan => puppetlabs-stdlib (>=4.6.0 <9.0.0)

Change

  • lib/ModuleDeclaration.ts: when :ref is absent, fall back to :tag. simpleGit().checkout() handles tag names, branch names, and SHAs the same way, so no other call site needs to change.
  • test/module.declaration.test.ts: new unit test that sets up a temporary git repo with a tag and asserts that mod '…', :git => '…', :tag => 'v1.0.0' yields declaration.ref === 'v1.0.0'.

Known side effect

PuppetFile.toText() only renders :ref => '{{ref}}'. A round-trip of a Puppetfile that used :tag will come out with :ref. Behaviourally equivalent for r10k, but worth mentioning if anyone diff-checks generated output. Not addressed here to keep the fix focused; happy to add a :tag field and template rendering in a follow-up if you want it.

A Puppetfile line with `mod 'x-y', :git => '...', :tag => 'v1'` is
valid r10k syntax, but the parser only knew about `:ref`. The `:tag`
parameter was silently dropped, `this.ref` stayed undefined, and
`fetchGitMetadata()` skipped the checkout step. metadata.json was then
read from the repository's default branch instead of the tagged commit,
which made the resolver pick up dependency ranges that the tag no
longer carries. The only symptom was an unrelated-looking range
conflict like `No possible version for requirement x => y (<9.0.0)`.

Treat `:tag` as an alias for `:ref`; simpleGit's checkout handles tags,
branches, and SHAs identically, so no other call site needs to change.
@dploeger

Copy link
Copy Markdown
Member

Supporting :tag in .toText would be nice as well, but as only we're using this, this PR should be sufficient for the moment.

@dploeger
dploeger merged commit ff96b28 into dodevops:main Nov 26, 2026
1 check passed
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