Skip to content

Commit 910f367

Browse files
fix(setup): warn about a half-set mothership before minting the key
mothershipOverride ran two steps after promptCopilotKey, so a half-set override minted a key against one environment, stored it, and only then warned that the other environment would reject it. Worse on a re-run: promptCopilotKey offers to keep an existing COPILOT_API_KEY and defaults to yes, so the bad key survives. Move the override ahead of the key prompt in both compose and dev, so the warning arrives while it can still change the outcome — the user can abort and set the missing half before anything is minted. Nothing in the override depends on the key, so the order is free.
1 parent 84d9fe9 commit 910f367

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

scripts/setup/modes/compose.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,13 @@ export async function runComposeMode(detection: Detection, quick: boolean): Prom
106106

107107
const root = readEnvFile('root')
108108
const values = collectSecrets(root)
109+
// Before the key is minted: a half-set override mints against one environment
110+
// and validates against the other, and warning afterwards is too late — the
111+
// bad key is already stored, and the next run offers to keep it.
112+
Object.assign(values, mothershipOverride())
109113
const copilotKey = await promptCopilotKey(root.vars.get('COPILOT_API_KEY'))
110114
if (copilotKey) values.COPILOT_API_KEY = copilotKey
111115
Object.assign(values, await promptLlmKeys(detection, !quick))
112-
Object.assign(values, mothershipOverride())
113116
if (!quick) {
114117
const storage = await promptStorage(root.vars, true)
115118
if (storage) Object.assign(values, storage)

scripts/setup/modes/dev.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,13 @@ export async function runDevMode(
118118

119119
const simAfter = readEnvFile('sim')
120120
const values: Record<string, string> = {}
121+
// Before the key is minted: a half-set override mints against one environment
122+
// and validates against the other, and warning afterwards is too late — the
123+
// bad key is already stored, and the next run offers to keep it.
124+
Object.assign(values, mothershipOverride())
121125
const copilotKey = await promptCopilotKey(simAfter.vars.get('COPILOT_API_KEY'))
122126
if (copilotKey) values.COPILOT_API_KEY = copilotKey
123127
Object.assign(values, await promptLlmKeys(detection, !quick))
124-
Object.assign(values, mothershipOverride())
125128

126129
// Redis is set up in every mode, quick included. Storage falls back to
127130
// PostgreSQL without it, but the pub/sub channels (live Chat task-status,

0 commit comments

Comments
 (0)