Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(agent/agentcontainers): ensure agent name env var is correct#18457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
DanielleMaywood merged 6 commits intomainfromdm-devcontainer-name-fix
Jun 19, 2025

Conversation

DanielleMaywood
Copy link
Contributor

Previously,CODER_WORKSPACE_AGENT_NAME would always be passed as the dev container name.

This is invalid for the following scenarios:

  • The dev container is specified in terraform
  • The dev container has a name customization

This change now runsReadConfig twice. The first read is to extract a name (if present), from thedevcontainer.json. The second read will then use the name we have stored for the dev container (so this could be either the customization, terraform resource name, or container name).

Previously, `CODER_WORKSPACE_AGENT_NAME` would always be passed as thedev container name.This is invalid for the following scenarios:- The dev container is specified in terraform- The dev container has a name customizationThis change now runs `ReadConfig` twice. The first read is to extract aname (if present), from the `devcontainer.json`. The second read willthen use the name we have stored for the dev container (so this could beeither the customization, terraform resource name, or container name).
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures the agent’s custom name fromdevcontainer.json is correctly applied to theCODER_WORKSPACE_AGENT_NAME environment variable by reading the config twice and updated tests to verify both reads.

  • ChangedreadConfigErrC channel capacity and added assertions for the first “empty” read.
  • Added a new subtest (CreateReadsConfigTwice) to cover custom-name override.
  • Updatedapi.go to runReadConfig once to extract the name and again to pass the proper env var.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

FileDescription
agent/agentcontainers/api_test.goIncreasereadConfigErrC capacity; assert empty vs. populated envs on two reads; new custom-name subtest
agent/agentcontainers/api.goCallReadConfig twice: first to pick upCoder.Name, second to inject it into the env
Comments suppressed due to low confidence (4)

agent/agentcontainers/api.go:1172

  • [nitpick] IfsubAgentConfig.Name is empty (no customization), this injects an emptyCODER_WORKSPACE_AGENT_NAME; consider defaulting explicitly to the container’s name (dc.Name) to avoid passing a blank value.
fmt.Sprintf("CODER_WORKSPACE_AGENT_NAME=%s", subAgentConfig.Name),

agent/agentcontainers/api_test.go:1896

  • There is no test covering the branch where the customization name is invalid; add a case that supplies an invalidCoder.Name and asserts that the warning path is triggered.
t.Run("CreateReadsConfigTwice", func(t *testing.T) {

agent/agentcontainers/api_test.go:1264

  • [nitpick] The variable namefakeDCCLI differs fromfDCCLI used in the new subtest; consider unifying the naming for clarity and consistency across tests.
fakeDCCLI = &fakeDevcontainerCLI{

agent/agentcontainers/api.go:1163

  • The local variablelogger is undefined here; useapi.logger.Warn to correctly reference the API’s logger instance.
logger.Warn(ctx, "invalid agent name in devcontainer customization, ignoring", slog.F("name", name))

@DanielleMaywoodDanielleMaywood marked this pull request as ready for reviewJune 19, 2025 13:58
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

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

Minor nit about log message but otherwise all good 👍🏻

Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

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

Optimization looks good 💪🏻

@DanielleMaywoodDanielleMaywood merged commitb49e62f intomainJun 19, 2025
34 checks passed
@DanielleMaywoodDanielleMaywood deleted the dm-devcontainer-name-fix branchJune 19, 2025 15:44
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 19, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

Copilot code reviewCopilotCopilot left review comments

@mafredrimafredrimafredri approved these changes

@johnstcnjohnstcnAwaiting requested review from johnstcn

Assignees

@DanielleMaywoodDanielleMaywood

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@DanielleMaywood@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp