Skip to content

Fix KAMAL_DESTINATION missing during alias ERB render - #1954

Open
vulragrag-star wants to merge 1 commit into
basecamp:mainfrom
vulragrag-star:fix/1953-alias-destination-env
Open

vulragrag-star wants to merge 1 commit into
basecamp:mainfrom
vulragrag-star:fix/1953-alias-destination-env

Conversation

@vulragrag-star

Copy link
Copy Markdown

Alias commands resolve through load_raw_config before create_from. Only create_from set ENV["KAMAL_DESTINATION"], so ERB that branches on that variable saw nil on the first render even when -d / --destination was on the command line.

This moves the env assignment into load_raw_config so alias resolution and normal config loading share the same behavior.

Fixes #1953

Test plan

  • bundle exec ruby -Itest test/configuration_test.rb -n /destination/ (5 runs, 0 failures)
  • Full test/configuration_test.rb (59 runs, 0 failures)
  • ./bin/test on CI

Alias resolution calls load_raw_config before create_from, so ERB that
branches on ENV["KAMAL_DESTINATION"] saw nil on the first pass even when
-d/--destination was on the command line. Set the env var in
load_raw_config so both paths share the same behavior.

Fixes basecamp#1953
Copilot AI balanced review requested due to automatic review settings September 14, 2026 10:51

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.

🟢 Approved

The shared loading path now matches existing configuration behavior and has focused regression coverage.

Pull request overview

Fixes #1953 by exposing the selected destination while ERB renders during alias resolution.

Changes:

  • Moves KAMAL_DESTINATION assignment into shared raw-config loading.
  • Adds regression coverage and destination-aware fixtures.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File summaries
File Description
lib/kamal/configuration.rb Sets the destination environment variable before raw ERB rendering.
test/configuration_test.rb Tests destination availability during raw loading.
test/fixtures/deploy_alias_needs_destination.yml Provides an alias configuration requiring the destination.
test/fixtures/deploy_alias_needs_destination.staging.yml Provides the destination-specific overlay.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

KAMAL_DESTINATION is unset while resolving aliases via load_raw_config

2 participants