feat: add bulk secret import upload to Add secret dialog (PLAT-240)#26725
Draft
dylanhuff-at-coder wants to merge 16 commits into
Draft
feat: add bulk secret import upload to Add secret dialog (PLAT-240)#26725dylanhuff-at-coder wants to merge 16 commits into
dylanhuff-at-coder wants to merge 16 commits into
Conversation
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Add POST /api/v2/users/{user}/secrets/batch to create many user secrets
from an uploaded env/json/yaml file. The batch is inserted in one
transaction, so any validation, uniqueness, or per-user-limit failure
rolls back everything and emits zero audit logs. Adds the codersdk
ImportUserSecrets client and the regenerated API docs.
Previously ParseSecretsFile set EnvName unconditionally to the file key for every parsed entry. This caused keys that are not valid POSIX env names (e.g. MY-TOKEN, my.key) or that are reserved (e.g. PATH) to fail ValidateCreateUserSecretRequest on the env_name field, rolling back the entire atomic batch import. Common real-world .env files typically contain such keys. Change EnvName assignment to best-effort: only set it when the key passes UserSecretEnvNameValid; otherwise leave EnvName empty. The secret is still imported, just without env injection. The env_name uniqueness index is a partial index (WHERE env_name != ''), so multiple empty env_names are fine. Update tests: - Add TestParseSecretsFileEnvBestEffortEnvName in codersdk with cases for hyphenated key (MY-TOKEN), reserved name (PATH), dot key (my.key), and a valid key (MY_TOKEN). - Remove ReservedEnvName (PATH) from the rollback failure cases in coderd/usersecretsimport_test.go; add TestImportUserSecretsReservedEnvNameBestEffort to assert the new success behavior (secret created, env_name empty).
…240) Add a file-upload dropzone to the create branch of the Add secret dialog (edit is unchanged). The browser reads the file, derives the format from the extension, and calls the import endpoint, surfacing per-entry backend errors. Includes Storybook coverage for success, partial-failure, and unsupported-file cases.
dylanhuff-at-coder
force-pushed
the
dylan/plat-240-secrets-import-frontend
branch
from
July 23, 2026 16:33
cd114ba to
22ab3cd
Compare
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds a file dropzone to the create branch of the Add secret dialog (final PR in the PLAT-240 stack, after #26723 and #26724). The browser reads the file, derives the format from the extension (
.env/.json/.yaml/.yml), and imports viaPOST /secrets/batch; per-entry backend errors surface in an alert and the success toast flags secrets imported without an env name. Storybook play stories and vitests cover the flow.Also documents the upload flow in
docs/user-guides/user-secrets.md.Closes https://linear.app/codercom/issue/PLAT-240