Skip to content

impl: fall back to CODER_HEADER_COMMAND when the header command setting is blank - #600

Open
folbricht-ant wants to merge 2 commits into
coder:mainfrom
folbricht-ant:header-command-env-fallback
Open

impl: fall back to CODER_HEADER_COMMAND when the header command setting is blank#600
folbricht-ant wants to merge 2 commits into
coder:mainfrom
folbricht-ant:header-command-env-fallback

Conversation

@folbricht-ant

@folbricht-ant folbricht-ant commented Aug 17, 2026

Copy link
Copy Markdown

The Coder CLI reads CODER_HEADER_COMMAND from the environment, and the VS Code extension falls back to it when coder.headerCommand is unset (src/settings/headers.ts). The Gateway plugin only honours its own setting, so on deployments behind an authenticating proxy every user has to paste the command into Settings by hand even when their environment already carries it.

This makes CoderSettings.headerCommand fall back to CODER_HEADER_COMMAND when the setting is blank — the same pattern sshConfigOptions already uses with CODER_SSH_CONFIG_OPTIONS, through the existing Environment seam. All consumers (REST client headers, the CLI exec environment, the --header-command written into the SSH config) read through that getter, so no call sites change. The settings UI comment now names the variable, like the SSH-options one does. An explicitly configured setting still wins.

Test: CoderSettingsTest.testHeaderCommand (state / env / precedence), mirroring testSSHConfigOptions.

Toolbox counterpart: coder/coder-jetbrains-toolbox#350

// requests. The command must output each header as `key=value` on its own
// line. The following environment variables will be available to the
// process: CODER_URL.
// process: CODER_URL. If blank, the CODER_HEADER_COMMAND environment

@fioan89 fioan89 Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have a couple of thoughts here. First I think mentioning CODER_URL might have been a mistake (from the past). We are not using that variable to resolve the header command. Now if the header command script uses it, then that is an implementation detail that should not leak here.

Second, the way it is phrased right now, one can understand that we fallback to CODER_HEADER_COMMAND if CODER_URL is empty. Right?

I would simply rephrase that the whole thing falls back to the CODER HEADER COMMAND env if available and if the user setting is empty, with no mention of CODER UL.

Everything else looks 👍

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point — done in a66796c: dropped the CODER_URL mention and reworded so the fallback clearly refers to the setting ("When this setting is blank, the CODER_HEADER_COMMAND environment variable is used instead, if set"), both here and in the settings UI text. Mirrored the same wording in coder/coder-jetbrains-toolbox#350.

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