DNM: feat!: add organization-scoped coderd_agents_default_model - #423
DNM: feat!: add organization-scoped coderd_agents_default_model#423ethanndickson wants to merge 8 commits into
Conversation
6638443 to
98d5bc3
Compare
98d5bc3 to
c5fbf17
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c5fbf17cc5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
92f104e to
a0e3b26
Compare
ab939e9 to
c918c14
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c918c1495d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
2d02b85 to
f152fdd
Compare
|
@codex review |
Add per-resource tfplugindocs templates (templates/resources/<name>.md.tmpl, templates/data-sources/<name>.md.tmpl) that set a subcategory front-matter field per resource/data source, so the Terraform Registry sidebar groups coderd_* pages into Agents, AI Governance, Deployment, Identity & Access Management, and Templates instead of listing them flat. The templates are copies of tfplugindocs' default resource template, minus the HasImportIDConfig/HasImportIdentityConfig branches: no resource ships import-by-string-id.tf or import-by-identity.tf example files, so those branches were always-false dead code. Data-source templates drop the import section entirely. Stacked on org-chat-models/default-model (#423): templates cover the renamed coderd_agents_default_model and this base's coderd_chat_system_prompt; when the stack rebases past #425, rename templates/resources/chat_system_prompt.md.tmpl to agents_system_prompt.md.tmpl. Regenerated docs/ with make gen; only the subcategory line changed per file.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f152fdd55d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f3b9705ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
1f3b970 to
78daa14
Compare
78daa14 to
efee9c8
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19eaf12e25
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| organizationID := state.OrganizationID.ValueUUID() | ||
| configs, err := r.experimentalClient().ChatModels(ctx, organizationID) | ||
| if err != nil { | ||
| if isHTTPNotFound(err) { |
There was a problem hiding this comment.
Treat Coder's 400 not-found response as deletion
When the collection lookup for an externally deleted or inaccessible organization returns Coder's known 400 "must be an existing uuid or username" response, isHTTPNotFound rejects it because it recognizes only status 404. Refresh then emits an error and retains the resource in state instead of allowing Terraform to recreate it. Use the shared isNotFound helper here so both server not-found representations follow the deletion path.
AGENTS.md reference: AGENTS.md:L73-L73
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49d64a31ed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| func (r *AgentsDefaultModelResource) agentsDefaultModelDiag(ctx context.Context, action string, organizationID, modelID uuid.UUID, err error) diag.Diagnostics { | ||
| var diags diag.Diagnostics | ||
| if !isHTTPNotFound(err) { |
There was a problem hiding this comment.
Handle alternate not-found responses during apply
When Create or Update targets an organization that Coder reports with its known 400 "must be an existing uuid or username" response, this check bypasses all model/organization probing and emits only a generic client error; the same problem occurs if a 404 PATCH is followed by that 400 from the collection or organization probe. Fresh evidence beyond the previously fixed Read path is that agentsDefaultModelDiag still uses the narrower isHTTPNotFound in all three checks, so use the shared isNotFound helper here as well to preserve the actionable missing-resource diagnosis.
AGENTS.md reference: AGENTS.md:L73-L73
Useful? React with 👍 / 👎.
|
@codex review re: Handle alternate not-found responses during apply Rejecting this finding. In the pinned Coder source, the exact 400 |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Add per-resource tfplugindocs templates (templates/resources/<name>.md.tmpl, templates/data-sources/<name>.md.tmpl) that set a subcategory front-matter field per resource/data source, so the Terraform Registry sidebar groups coderd_* pages into Agents, AI Governance, Deployment, Identity & Access Management, and Templates instead of listing them flat. The templates are copies of tfplugindocs' default resource template, minus the HasImportIDConfig/HasImportIdentityConfig branches: no resource ships import-by-string-id.tf or import-by-identity.tf example files, so those branches were always-false dead code. Data-source templates drop the import section entirely. Stacked on org-chat-models/default-model (#423): templates cover the renamed coderd_agents_default_model and this base's coderd_chat_system_prompt; when the stack rebases past #425, rename templates/resources/chat_system_prompt.md.tmpl to agents_system_prompt.md.tmpl. Regenerated docs/ with make gen; only the subcategory line changed per file.
Caution
DNM: Coder will likely drop the
/experimental/prefix from these API routes in 2.37 and replace it with/v2/. That hasn't happened upstream yet — hold this PR until it's settled so the pinned SDK targets the final routes.Stacked on #422.
Coder 2.37 makes the default chat model per-organization rather than deployment-global (coder/coder#27957, coder/coder#28442): each organization now has its own default, the first model created in an organization is auto-promoted, and existing configs were migrated to the default organization. The experimental
coderd_default_agents_modelresource modeled a single global default — a constant"default"id, a global list lookup, and import by model UUID — which no longer matches the server.This PR replaces it with the organization-scoped
coderd_agents_default_modelresource:coderd_default_agents_modeltocoderd_agents_default_model, grouping it withcoderd_agents_modeland treating the organization-scoped behavior as a new experimental resource.organization_idattribute: the target organization must be stated explicitly (deliberately stricter than the optional-with-default pattern used bycoderd_agents_mcp_server/coderd_agents_model, since promoting a default silently demotes the previous one); changing it forces replacement.idis the organization UUID, since each organization has exactly one default.is_default: true; a 404 is surfaced as an actionable diagnostic naming the endpoint and the minimum Coder version. Setting a model from another organization as the default fails with the server's 400.Readlists the organization's models and resolves the default; if the organization or default is gone, the resource is removed from state.Breaking changes and migration:
coderd_default_agents_modelis removed and replaced bycoderd_agents_default_model.MoveStatemigration is provided. The old resource was experimental, and its Terraform state represented a default selection rather than an independently deletable server object.terraform state rm coderd_default_agents_model.<name>, then declarecoderd_agents_default_model. Forgetting the old state does not clear or otherwise change Coder's server-side default.model_idis resolved on read.organization_idis required.Closes CODAGT-973