Skip to content

fix!: enforce agent names be case-insensitive-unique per-workspace #16614

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Feb 19, 2025

Relates to coder/coder-desktop-macos#54

Currently, it's possible to have two agents within the same workspace whose names only differ in capitalization:
This leads to an ambiguity in two cases:

  • For CoderVPN, we'd like to allow support to workspaces with a hostname of the form: agent.workspace.username.coder.
  • Workspace apps (coder_apps) currently use subdomains of the form: <app>--<agent>--<workspace>--<username>(--<suffix>)?.

Of note is that DNS hosts must be strictly lower case, hence the ambiguity.

This fix is technically a breaking change, but only for the incredibly rare use case where a user has:

  • A workspace with two agents
  • Those agent names differ only in capitalization.

Those templates & workspaces will now fail to build. This can be fixed by choosing wholly unique names for the agents.

Copy link
Member Author

@ethanndickson ethanndickson force-pushed the ethan/case-insensitive-unique-agent-names branch from ea0c978 to 5241805 Compare February 19, 2025 05:30
@ethanndickson ethanndickson force-pushed the ethan/case-insensitive-unique-agent-names branch from 5241805 to 566e3de Compare February 19, 2025 05:50
@ethanndickson ethanndickson marked this pull request as ready for review February 19, 2025 05:57
@ethanndickson ethanndickson added the release/breaking This label is applied to PRs to detect breaking changes as part of the release process label Feb 19, 2025
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

I had no idea this was allowed 🤯, nice find!

Should we add this guard on the provider as well? I'm thinking we can surface the error faster/better over there. I absolutely think it's worth guarding the input here as well, though.

@ethanndickson
Copy link
Member Author

ethanndickson commented Feb 19, 2025

Should we add this guard on the provider as well? I'm thinking we can surface the error faster/better over there. I absolutely think it's worth guarding the input here as well, though.

Unfortunately not possible, since we derive the agent name from the name of the resource, which the provider SDK purposefully doesn't expose to us :( [1]

i.e. for resource "coder_agent" "agent_name" there's no way in the provider Go code to read agent_name.

For the same reason, you can't use the for_each meta-argument with agents.

Copy link
Member Author

ethanndickson commented Feb 20, 2025

Merge activity

  • Feb 19, 8:51 PM EST: A user started a stack merge that includes this pull request via Graphite.
  • Feb 19, 8:51 PM EST: A user merged this pull request with Graphite.

@ethanndickson ethanndickson merged commit 3fddfef into main Feb 20, 2025
45 checks passed
@ethanndickson ethanndickson deleted the ethan/case-insensitive-unique-agent-names branch February 20, 2025 01:51
aslilac pushed a commit that referenced this pull request Feb 21, 2025
…16614)

Relates to coder/coder-desktop-macos#54

Currently, it's possible to have two agents within the same workspace whose names only differ in capitalization:
This leads to an ambiguity in two cases:
- For CoderVPN, we'd like to allow support to workspaces with a hostname of the form: `agent.workspace.username.coder`.
- Workspace apps (`coder_app`s) currently use subdomains of the form: `<app>--<agent>--<workspace>--<username>(--<suffix>)?`.

Of note is that DNS hosts must be strictly lower case, hence the ambiguity.

This fix is technically a breaking change, but only for the incredibly rare use case where a user has:
- A workspace with two agents
- Those agent names differ only in capitalization.

Those templates & workspaces will now fail to build. This can be fixed by choosing wholly unique names for the agents.
aslilac pushed a commit that referenced this pull request Feb 27, 2025
…16614)

Relates to coder/coder-desktop-macos#54

Currently, it's possible to have two agents within the same workspace whose names only differ in capitalization:
This leads to an ambiguity in two cases:
- For CoderVPN, we'd like to allow support to workspaces with a hostname of the form: `agent.workspace.username.coder`.
- Workspace apps (`coder_app`s) currently use subdomains of the form: `<app>--<agent>--<workspace>--<username>(--<suffix>)?`.

Of note is that DNS hosts must be strictly lower case, hence the ambiguity.

This fix is technically a breaking change, but only for the incredibly rare use case where a user has:
- A workspace with two agents
- Those agent names differ only in capitalization.

Those templates & workspaces will now fail to build. This can be fixed by choosing wholly unique names for the agents.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release/breaking This label is applied to PRs to detect breaking changes as part of the release process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants