Skip to content

fix: use string literals for mage alias keys - #8296

Merged
macdewee merged 4 commits into
mainfrom
drosiek-fix-mage-aliases
Nov 20, 2026
Merged

macdewee merged 4 commits into
mainfrom
drosiek-fix-mage-aliases

Conversation

@macdewee

Copy link
Copy Markdown
Contributor

What is the problem this PR solves?

#8248 replaced the "build" and "test" keys of the Aliases map in magefile.go with the cmdBuild and cmdTest constants to satisfy goconst. Mage only discovers aliases whose keys are string literals (parse.go requires an *ast.BasicLit key and otherwise logs warning: alias key is not a string literal and skips it), so the build and test aliases were silently dropped.

How does this PR solve the problem?

Restores the string-literal keys. The "build" key keeps a //nolint:goconst with an explanation, and a comment above Aliases explains why the constants must not be used there. "test" needs no nolint (nolintlint reports it as unused). The constants stay in use elsewhere in the file.

The same change is already included in the backports of #8248 (#8286, #8287, #8288, #8289).

How to test this PR locally

Run mage check:go; it should pass. The alias keys are plain string literals again, so mage build and mage test resolve to build:binary and test:all as before #8248.

Checklist

  • I have commented my code, particularly in hard-to-understand areas

Related issues

🤖 Generated with Claude Code

macdewee and others added 2 commits November 19, 2026 09:39
Mage only discovers aliases whose keys are string literals; using the
cmdBuild/cmdTest constants silently dropped the build and test aliases.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@macdewee macdewee added bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team skip-changelog labels Nov 19, 2026
Copilot AI balanced review requested due to automatic review settings November 19, 2026 11:50
@macdewee macdewee self-assigned this Nov 19, 2026
@mergify

mergify Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

This pull request does not have a backport label. Could you fix it @macdewee? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the change restoring Fleet Server’s Mage build and test aliases.

No open issues 🎉

What changed in this PR

Restores Fleet Server’s mage build and mage test aliases after #8248 replaced their string-literal keys with constants that Mage’s alias parser skips.

Changes:

  • Restores literal keys mapping build to Build.Binary and test to Test.All.
  • Documents Mage’s literal-key requirement and adds a targeted goconst suppression for "build".
File Description
magefile.go Restores discoverable alias keys and documents why constants cannot be used.

Review effort: Balanced

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 12:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the change restoring Mage’s build and test alias discovery.

No open issues 🎉

Review effort: Balanced

@macdewee
macdewee marked this pull request as ready for review November 19, 2026 13:02
@macdewee
macdewee requested a review from a team as a code owner November 19, 2026 13:02
@macdewee
macdewee requested a review from ycombinator November 19, 2026 13:02
@mergify

mergify Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@macdewee
macdewee enabled auto-merge (squash) November 19, 2026 13:55
@macdewee
macdewee disabled auto-merge November 19, 2026 13:57
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the Mage alias restoration.

No open issues 🎉

Review effort: Balanced

@macdewee
macdewee enabled auto-merge (squash) November 19, 2026 14:46

@ycombinator ycombinator left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed by looking at output of mage -v build and mage -v test on this PR. LGTM.

@macdewee
macdewee merged commit a9f6e15 into main Nov 20, 2026
26 checks passed
@macdewee
macdewee deleted the drosiek-fix-mage-aliases branch November 20, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants