fix(dev): don't fail env sync on an empty local Secrets Store - #5331
Merged
Conversation
`dev:env --missing-secrets-only` re-listed the local Secrets Store at apply time and treated any non-zero wrangler exit as fatal. Wrangler's local `secrets-store secret list` exits 1 with "List request returned no secrets." when the store is empty, so the first env sync in a fresh worktree aborted on the first worker whose per-worktree `.wrangler` store had no secrets yet. The re-check was also redundant: computePlan prefetches the same listing and already skips secrets that exist when source-backed refresh is off, and it deliberately tolerates a failed listing. Drop the apply-time listing so apply just creates what the plan selected, which also removes one wrangler invocation per store per run.
eshurakov
approved these changes
Aug 18, 2026
Contributor
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Reviewed by kimi-k3 · Input: 70K · Output: 5.1K · Cached: 304.6K Review guidance: REVIEW.md from base branch |
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.
Problem
The first
pnpm dev:env --missing-secrets-onlyrun in a fresh worktree fails while setting up Cloudflare workers:--missing-secrets-only(added in #5256) re-listed the local Secrets Store at apply time viasecretExists()and threw on any non-zero wrangler exit. Wrangler's localsecrets-store secret listexits1withList request returned no secrets.when the store is empty — exactly the state of a fresh worktree, since Secrets Store persistence lives under each worker's per-worktree.wranglerdirectory. So the sync aborted on the first worker with an empty local store.Fix
Drop the apply-time listing. It was redundant with the planner, which already:
plan.tsloadLocalStoreSecrets), and--missing-secrets-only/--checkmode (plan.ts:833), andplan.ts:399,plan.ts:417).Apply now just creates what the plan selected, so it no longer contradicts the plan. Side effect: one fewer
wrangler secrets-store secret listper store per run, in line with what #5256 was after.Verification
tsx dev/local/cli.ts env -y --missing-secrets-onlyin a fresh worktree: completes, creates the missing secret, exit 0 (previously exit 1).pnpm run test:dev-local— 212 pass;output.test.tsupdated to assert apply creates the planned secrets concurrently and never issues alistcall.pnpm formatclean.