{"record":{"id":"9288ce8f43daba87","repo":"can1357/oh-my-pi","slug":"omp-auth-broker-migrate-requires-an-explicit-sou","errorCode":null,"errorMessage":"`omp auth-broker migrate` requires an explicit source. Pass `--from-local` to migrate from the local SQLite store and env vars.","messagePattern":"`omp auth-broker migrate` requires an explicit source\\. Pass `--from-local` to migrate from the local SQLite store and env vars\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/auth-broker-cli.ts","lineNumber":765,"sourceCode":"\tconst orgSuffix = credential.orgId ? `|org:${credential.orgId}` : \"\";\n\tif (credential.email && ids.has(`email:${credential.email}${orgSuffix}`)) return true;\n\tif (credential.accountId && ids.has(`accountId:${credential.accountId}${orgSuffix}`)) return true;\n\tif (credential.projectId && ids.has(`projectId:${credential.projectId}${orgSuffix}`)) return true;\n\tif (!credential.email && !credential.accountId && !credential.projectId && credential.orgId) {\n\t\treturn ids.has(`org:${credential.orgId}`);\n\t}\n\treturn false;\n}\n\nasync function runMigrate(flags: AuthBrokerCommandArgs[\"flags\"]): Promise<void> {\n\tconst brokerConfig = await resolveAuthBrokerConfig();\n\tif (!brokerConfig) {\n\t\tthrow new Error(\n\t\t\t\"OMP_AUTH_BROKER_URL must be set (or `auth.broker.url` in config.yml). `migrate` uploads local credentials to a configured broker.\",\n\t\t);\n\t}\n\tif (flags.fromLocal !== true) {\n\t\tthrow new Error(\n\t\t\t\"`omp auth-broker migrate` requires an explicit source. Pass `--from-local` to migrate from the local SQLite store and env vars.\",\n\t\t);\n\t}\n\n\tconst client = new AuthBrokerClient({ url: brokerConfig.url, token: brokerConfig.token });\n\tconst snapshotResult = await client.fetchSnapshot();\n\tif (snapshotResult.status !== 200) throw new Error(\"Auth broker returned no snapshot\");\n\tconst existing = indexBrokerSnapshot(snapshotResult.snapshot);\n\n\tconst plan: MigratePlanEntry[] = [];\n\tconst skipped: MigrateSkip[] = [];\n\n\t// 1. Local SQLite rows.\n\tconst localDbPath = getAgentDbPath();\n\tconst localStore = await SqliteAuthCredentialStore.open(localDbPath);\n\tconst plannedApiKeyProviders = new Set<string>();\n\ttry {\n\t\tfor (const row of localStore.listAuthCredentials()) {","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/auth-broker-cli.ts#L747-L783","documentation":"Migrate requires the user to explicitly opt in to the credential source. Even with a broker configured, `runMigrate` throws unless `flags.fromLocal` is exactly `true`, because uploading the local SQLite store and env vars is an explicit, potentially sensitive action. This guards against accidental pushes from the wrong machine.","triggerScenarios":"Running `omp auth-broker migrate` with a broker URL configured but without `--from-local`; passing unsupported flags (`--from-file`); a typo like `--fromlocal` that parses to nothing.","commonSituations":"Following an older guide that omitted the flag; assuming migration starts automatically once the broker URL is set; scripted runs passing only the broker env var.","solutions":["Re-run with the explicit source flag: `omp auth-broker migrate --from-local`.","Check flag spelling (`--from-local`, hyphenated) so it parses into `flags.fromLocal`.","Review the migration scope first (e.g. `--dry-run` if available), then run the real migration."],"exampleFix":"// before\nomp auth-broker migrate\n// after\nOMP_AUTH_BROKER_URL=https://broker.example.com omp auth-broker migrate --from-local","handlingStrategy":"validation","validationCode":"const flags: AuthBrokerCommandArgs[\"flags\"] = { fromLocal: true };\nif (flags.fromLocal !== true) {\n  console.error(\"migrate requires explicit --from-local\");\n  process.exit(2);\n}\nawait runMigrate(flags);","typeGuard":null,"tryCatchPattern":"try {\n  await runMigrate(flags);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"requires an explicit source\")) {\n    console.error(\"Re-run with --from-local to migrate from the local SQLite store and env vars.\");\n  } else throw err;\n}","preventionTips":["Always include `--from-local` when invoking migrate.","Watch flag hyphenation: `--from-local`, not `--fromlocal`.","Run with a dry-run/preview first to confirm the upload scope."],"tags":["cli","usage","missing-flag"],"backgroundTag":"missing-required-flag","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}