Skip to content

Name the subcommand for hooks and output logs run through Main - #1963

Merged
djmb merged 1 commit into
mainfrom
fix-subcommand-env
Oct 13, 2026
Merged

djmb merged 1 commit into
mainfrom
fix-subcommand-env

Conversation

@jeremy

@jeremy jeremy commented Oct 8, 2026

Copy link
Copy Markdown
Member

Running a subcommand from the command line never told anyone which subcommand it was. kamal app boot gave its hooks KAMAL_COMMAND=app and no KAMAL_SUBCOMMAND, and an output logger named its file …_app.log rather than …_app_boot.log. The OTel logger's command was app as well.

subcommand looked only at the first invocation Thor recorded. Run through Main, that's Main's own app, which dispatches to App's boot, so the subcommand always came out nil. The tests didn't notice because they call Kamal::Cli::App.start directly, where App's invocation is the first one.

When the first invocation is Main running a subcommand, this looks up that subcommand class's own first invocation instead. Top-level commands are unchanged: kamal deploy still has no subcommand, even though it invokes app boot along the way, and kamal proxy reboot is still proxy reboot through the app boot it invokes. The lookup doesn't add an entry to Thor's invocations hash, so it can't affect the invoke bookkeeping that reset_invocation relies on.

The new test runs kamal app boot through Main.start and checks both the hook's environment and the modify.kamal payload the output loggers name their files from. It fails on main ({"KAMAL_COMMAND" => "app"}).

Unit suite: 861 runs. The only failures are the 7 that also fail on main without a Docker builder (CliBuildTest ×4, CommandsBuilderTest ×2, ConfigurationBuilderTest ×1). RuboCop is clean.

`kamal app boot` records Main's `app` invocation before App's `boot`, and
the subcommand was only taken from the first invocation, so every real
subcommand run from the command line came out as nil: hooks got no
KAMAL_SUBCOMMAND and output logs were named `app` rather than `app_boot`.
Tests calling the subcommand class directly record App's invocation
first, which is why they didn't notice.

When the first invocation is Main running a subcommand, look up that
subcommand class's own first invocation instead.
Copilot AI balanced review requested due to automatic review settings October 8, 2026 20:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T20:59:42.967312Z 12542af PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@jeremy
jeremy added this pull request to stack #1965 October 8, 2026 21:01
@jeremy
jeremy requested a review from djmb October 8, 2026 21:01
@djmb
djmb merged commit 1b63e8c into main Oct 13, 2026
12 of 13 checks passed
@djmb
djmb deleted the fix-subcommand-env branch October 13, 2026 10:15
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.

3 participants