Skip to content

fix(agent): don't overwrite existing vscode git auth settings#22871

Merged
zedkipp merged 1 commit intomainfrom
zedkipp/vscode-settings
Mar 12, 2026
Merged

fix(agent): don't overwrite existing vscode git auth settings#22871
zedkipp merged 1 commit intomainfrom
zedkipp/vscode-settings

Conversation

@zedkipp
Copy link
Contributor

@zedkipp zedkipp commented Mar 9, 2026

OverrideVSCodeConfigs previously unconditionally set git.useIntegratedAskPass and github.gitAuthentication to false, clobbering any values provided by template authors via module settings (e.g. the vscode-web module's settings block). This change only set these keys when they are not already present, so template-provided values are preserved.

Registry PR #758 fixed the module side (run.sh merges template-author settings into the existing settings.json instead of overwriting the file). But the agent still unconditionally stamped false onto both keys before the script ran, so the merge base always contained the agent's values and template authors couldn't set them to anything else. This change fixes the agent side by only writing defaults when the keys are absent.

#19007

Test Plan

Prerequisites:

Start develop.sh with an external auth provider configured:

CODER_EXTERNAL_AUTH_0_ID=test-github CODER_EXTERNAL_AUTH_0_TYPE=github CODER_EXTERNAL_AUTH_0_CLIENT_ID=fake CODER_EXTERNAL_AUTH_0_CLIENT_SECRET=fake scripts/develop.sh

Use a template with the vscode-web module overriding the git auth settings (ensure version 1.5.0):

    module "vscode-web" {
      count          = data.coder_workspace.me.start_count
      source         = "registry.coder.com/modules/vscode-web/coder"
      version        = "1.5.0"
      agent_id       = coder_agent.main.id
      accept_license = true

      settings = {
        "git.useIntegratedAskPass" = true
        "github.gitAuthentication" = true
      }
    }

Tests:

  1. Fresh start: create a workspace, verify the module's true values survive the agent's defaults:
    coder ssh <workspace> -- cat '~/.vscode-server/data/Machine/settings.json'
    Expected: both keys are true.

  2. Restart: restart the workspace, verify the agent doesn't clobber them back to false :

    coder restart <workspace>
    coder ssh <workspace> -- cat '~/.vscode-server/data/Machine/settings.json'
    

    Expected: both keys are still true .

OverrideVSCodeConfigs previously unconditionally set
git.useIntegratedAskPass and github.gitAuthentication to false,
clobbering any values provided by template authors via module
settings (e.g. the vscode-web module's settings block).

Change mutate to only set these keys when they are not already
present, so template-provided values are preserved.

Fixes #19007
@zedkipp zedkipp marked this pull request as ready for review March 12, 2026 15:54
Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

With the test added, it looks good to me. Thanks, I thought we solved this issue on the module side in coder/registry#758. But good to see the complete fix. Thanks.

@zedkipp zedkipp merged commit 2488cf0 into main Mar 12, 2026
41 checks passed
@zedkipp zedkipp deleted the zedkipp/vscode-settings branch March 12, 2026 19:39
@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent unconditionally overwrites VS Code git auth settings configured by template authors

2 participants