Skip to content

pro --help lists computer-groups twice; the registry registers it on two lines #362

Description

@ktn-jamf

jamf-cli version

main at 5c77d4d. Present in every released version that carries the resource.

Product namespace

pro (Jamf Pro / Platform API)

Auth method

not applicable — the defect is in command registration

OS / platform

All

Command run

jamf-cli pro --help

Expected behavior

Each resource appears once in the command list.

Actual behavior

computer-groups appears twice. Counted on the built binary: two rows.

Anything else?

Cause. internal/commands/pro/generated/registry.go registers the same constructor on two consecutive lines:

71:	root.AddCommand(NewComputerGroupsCmd(ctx))
72:	root.AddCommand(NewComputerGroupsCmd(ctx))

It is the only duplicate in the registry. Checked by extracting every New…Cmd(ctx) call and looking for repeats; NewComputerGroupsCmd is the sole result.

What it costs. No capability is lost, because the two subtrees are identical. Three smaller costs:

  1. pro --help is wrong, and a duplicated row reads as a defect to anyone using the output.
  2. Cobra's Find resolves every path under computer-groups to the first copy, so the second whole command tree is unreachable. It is built at every process start and never used.
  3. It inflates any count taken by walking the command tree by one. A test that walks the tree and reports a leaf count reports 1437 where 1436 commands are reachable.

This is a generated file, so the fix belongs in the generator, not in registry.go, which make generate overwrites. The emitter is registryTemplate in generator/parser/generator.go. The likely cause is a resource reaching the registry list twice — for example surviving both a family split and a version dedupe — so the fix is to make the emitter refuse or collapse a repeated constructor rather than to delete one line by hand.

A guard would be worth more than the fix: the emitter can fail when it is about to register the same constructor twice, so the next occurrence cannot reach a release. make verify-generated cannot see this, because the duplicate is faithfully reproduced by the generator and the tree is therefore "up to date".

How it was found. #360 walks every leaf of the command tree, and its allowlist recorded pro computer-groups get as an example that "resolves to a same-named sibling". The real cause is this duplicate, so that comment sent a reader looking for an example problem. #360 corrects the comment and does not fix the registry, this being a separate generator concern.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions