Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: validate coder_secret requirements in dynamic parameters - #24697

Closed
dylanhuff-at-coder wants to merge 3 commits into
mainfrom
dylan/plat-100-integrate-secret-requirements-into-dynamic-parameters
Closed

feat: validate coder_secret requirements in dynamic parameters#24697
dylanhuff-at-coder wants to merge 3 commits into
mainfrom
dylan/plat-100-integrate-secret-requirements-into-dynamic-parameters

Conversation

@dylanhuff-at-coder

@dylanhuff-at-coder dylanhuff-at-coder commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Integrates coder_secret requirements from the preview renderer into dynamic parameter evaluation. Missing owner secrets now surface as dynamic parameter diagnostics, with UI guidance for coder secret create; callers without secret read access get a non-blocking validation warning.

Workspace starts enforce missing secrets, while stop and delete transitions filter those diagnostics so unmet secret requirements do not prevent cleanup.

Refs PLAT-100

@dylanhuff-at-coder
dylanhuff-at-coder force-pushed the dylan/plat-100-integrate-secret-requirements-into-dynamic-parameters branch from b5e46ab to 6d771c8 Compare April 23, 2026 22:12
@dylanhuff-at-coder

Copy link
Copy Markdown
Contributor Author

/coder-agents-review

Unmet template `coder_secret` requirements now surface as missing_secret
diagnostics on the create-workspace page, disabling Create Workspace
until the owner satisfies them and pointing at the `coder secret create`
CLI docs for recovery.

Secret metadata is read under the caller's own authorization context.
Non-owners (e.g. admins rendering for another user) lack user_secret:read
on the target per the User Secrets RFC, so they see a
secret_validation_forbidden warning instead. This avoids a side-channel
where a non-owner could enumerate a target user's secret env_names and
file_paths by watching for missing_secret diagnostics. NotAuthorized
denials are cached for the websocket lifetime; successes and transient
errors re-fetch every render so that following the CLI guidance in
another tab is picked up without a page reload.

Refs PLAT-100.
@dylanhuff-at-coder
dylanhuff-at-coder force-pushed the dylan/plat-100-integrate-secret-requirements-into-dynamic-parameters branch from 6d771c8 to a394903 Compare April 23, 2026 23:02

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean authorization design, well-constructed anti-enumeration defense, and a test suite that proves what it claims. The TestDynamicRender_NonOwnerCannotLeakSecretRequirements test is a standout: it seeds a matching secret and verifies the non-owner still cannot observe satisfaction, which is the right way to pin an information-leak fix. The caching strategy (deny-only cache, live-refetch on success) is a deliberate UX choice that the code and tests document well.

1 P1, 1 P2, 6 P3, 2 P4, 3 Nit.

The P1 is the load-bearing issue: checkSecretRequirements emits hcl.DiagError for missing secrets, and ResolveParameters gates on diags.HasErrors() for ALL build transitions. A user who deletes a required secret (or whose template adds one) cannot stop or delete their workspace. Auto-delete is safe (non-owner warning path), but user-initiated stop/delete is not.

"What happens at three users: nothing. What happens when coder_secret adoption grows and template admins start adding secret blocks to established templates: workspaces become unstoppable." Hisoka

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/dynamicparameters/render.go
Comment thread coderd/dynamicparameters/render_internal_test.go
Comment thread site/src/modules/workspaces/DynamicParameter/DynamicParameter.tsx Outdated
Comment thread coderd/dynamicparameters/render.go Outdated
Comment thread coderd/dynamicparameters/render.go
Comment thread coderd/dynamicparameters/render.go
Comment thread coderd/dynamicparameters/render_internal_test.go Outdated
Comment thread coderd/dynamicparameters/render.go Outdated
Comment thread coderd/dynamicparameters/render.go Outdated
@dylanhuff-at-coder
dylanhuff-at-coder marked this pull request as ready for review April 24, 2026 19:16
@dylanhuff-at-coder dylanhuff-at-coder changed the title fix: grant AsAIBridged ResourceSystem.ActionCreate for UpsertAISeatSt… feat: validate coder_secret requirements in dynamic parameters Apr 24, 2026
@dylanhuff-at-coder

Copy link
Copy Markdown
Contributor Author

Added @aslilac and @jeremyruppel for a frontend review :)

@jeremyruppel jeremyruppel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

frontend changes look great to me! thank you for all the tests! 🙏

@zedkipp

zedkipp commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

I like how this will not be visible to existing users creating workspaces unless they have coder_secret in the template.

When I tried this locally, I see the errors about the missing secrets but the error messages don't really tell me how to fix it as a user. The help messages seem to be printed, but that doesn't tell me what environment variable name or file path my secret must have defined.
Screenshot 2026-04-24 at 3 54 53 PM

Comment thread go.mod
github.com/coder/aisdk-go v0.0.9
github.com/coder/boundary v0.8.4-0.20260304164748-566aeea939ab
github.com/coder/preview v1.0.8
github.com/coder/preview v1.0.9-0.20260422211932-5e77eadfa551

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should probably make and use the 1.0.9 official tag in coder/preview here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Chatted in DMs with Dylan and we're going to revisit this to more closely align with the Figma mockups/design

@aslilac aslilac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just one small note, the frontend code seems fine

@@ -4,7 +4,7 @@ import (
"context"
"database/sql"
"io/fs"
"log/slog"
stdslog "log/slog"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why are we bringing in two slog libraries? I can only find one other reference to "log/slog" in the codebase, so I think this deserves a bit of justification

@dylanhuff-at-coder

Copy link
Copy Markdown
Contributor Author

I'm closing this PR without merging, the scope and size increased with UI improvements that were needed for this work. I'm replacing this with a set of PRs:
#24785
#24786
#24787

@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 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.

4 participants