can1357/oh-my-pi · error

OMP_AUTH_BROKER_URL must be set (or `auth.broker.url` in con

Error message

OMP_AUTH_BROKER_URL must be set (or `auth.broker.url` in config.yml). `migrate` uploads local credentials to a configured broker.

What it means

`runMigrate` uploads local credentials to a remote auth broker, so broker configuration is mandatory. It resolves config via `resolveAuthBrokerConfig()` (env `OMP_AUTH_BROKER_URL` or `auth.broker.url` in config.yml); when neither yields a config it throws with instructions naming both sources, preventing a silent no-op migration.

Source

Thrown at packages/coding-agent/src/cli/auth-broker-cli.ts:760

function brokerAlreadyHas(existing: Map<string, Set<string>>, provider: string, credential: AuthCredential): boolean {
	const ids = existing.get(provider);
	if (!ids) return false;
	if (credential.type === "api_key") return ids.has("@api_key");
	const orgSuffix = credential.orgId ? `|org:${credential.orgId}` : "";
	if (credential.email && ids.has(`email:${credential.email}${orgSuffix}`)) return true;
	if (credential.accountId && ids.has(`accountId:${credential.accountId}${orgSuffix}`)) return true;
	if (credential.projectId && ids.has(`projectId:${credential.projectId}${orgSuffix}`)) return true;
	if (!credential.email && !credential.accountId && !credential.projectId && credential.orgId) {
		return ids.has(`org:${credential.orgId}`);
	}
	return false;
}

async function runMigrate(flags: AuthBrokerCommandArgs["flags"]): Promise<void> {
	const brokerConfig = await resolveAuthBrokerConfig();
	if (!brokerConfig) {
		throw new Error(
			"OMP_AUTH_BROKER_URL must be set (or `auth.broker.url` in config.yml). `migrate` uploads local credentials to a configured broker.",
		);
	}
	if (flags.fromLocal !== true) {
		throw new Error(
			"`omp auth-broker migrate` requires an explicit source. Pass `--from-local` to migrate from the local SQLite store and env vars.",
		);
	}

	const client = new AuthBrokerClient({ url: brokerConfig.url, token: brokerConfig.token });
	const snapshotResult = await client.fetchSnapshot();
	if (snapshotResult.status !== 200) throw new Error("Auth broker returned no snapshot");
	const existing = indexBrokerSnapshot(snapshotResult.snapshot);

	const plan: MigratePlanEntry[] = [];
	const skipped: MigrateSkip[] = [];

	// 1. Local SQLite rows.

View on GitHub (pinned to 9690622007)

Solutions

  1. Set `OMP_AUTH_BROKER_URL=https://<broker-host>` in the environment and re-run.
  2. Add `auth.broker.url: https://<broker-host>` to your config.yml.
  3. If you don't intend to upload to a broker, don't run `migrate` — manage local credentials with `login`/`logout`.

Example fix

// before
omp auth-broker migrate   // no broker configured
// after
export OMP_AUTH_BROKER_URL=https://broker.example.com
omp auth-broker migrate --from-local
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.OMP_AUTH_BROKER_URL) {
  // or verify auth.broker.url exists in config.yml before invoking
  console.error("Set OMP_AUTH_BROKER_URL or auth.broker.url in config.yml before migrate.");
  process.exit(1);
}
await runMigrate({ fromLocal: true });

Try / catch

try {
  await runMigrate({ fromLocal: true });
} catch (err) {
  if (err instanceof Error && err.message.includes("OMP_AUTH_BROKER_URL must be set")) {
    console.error("Configure OMP_AUTH_BROKER_URL or auth.broker.url, then retry.");
  } else throw err;
}

Prevention

When it happens

Trigger: Running `omp auth-broker migrate` where `OMP_AUTH_BROKER_URL` is unset in the environment and no `auth.broker.url` key exists in config.yml, or the config file isn't being loaded (wrong path/profile).

Common situations: Fresh workstation before configuring the broker; config.yml present but the key misnamed or wrongly nested; CI job that doesn't export `OMP_AUTH_BROKER_URL`.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/3ad2b8c4f7fe2950. Report an issue: GitHub.