can1357/oh-my-pi · error · AIError.ConfigurationError
OMP_AUTH_BROKER_ACCOUNT_POOL_FILE must contain a JSON object
Error message
OMP_AUTH_BROKER_ACCOUNT_POOL_FILE must contain a JSON object
What it means
After the pool file is successfully parsed, loadAuthBrokerAccountPool validates its shape: it must be a non-null, non-array JSON object whose keys are provider ids and whose values are identity-key arrays. A file containing a bare string, number, boolean, null, or a JSON array is rejected with this ConfigurationError, since the loader needs an object to map providers to identity sets.
Source
Thrown at packages/ai/src/auth-broker/discover.ts:131
}
}
return {};
}
export async function loadAuthBrokerAccountPool(): Promise<AuthBrokerAccountPool | undefined> {
const filePath = process.env.OMP_AUTH_BROKER_ACCOUNT_POOL_FILE?.trim();
if (!filePath) return undefined;
let parsed: unknown;
try {
parsed = await Bun.file(filePath).json();
} catch (error) {
throw new AIError.ConfigurationError(`Unable to read OMP_AUTH_BROKER_ACCOUNT_POOL_FILE at ${filePath}`, {
cause: error,
});
}
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
throw new AIError.ConfigurationError("OMP_AUTH_BROKER_ACCOUNT_POOL_FILE must contain a JSON object");
}
const accountPool = new Map<string, ReadonlySet<string>>();
for (const [provider, value] of Object.entries(parsed)) {
const normalizedProvider = provider.trim();
if (normalizedProvider.length === 0) {
throw new AIError.ConfigurationError("OMP_AUTH_BROKER_ACCOUNT_POOL_FILE contains an empty provider id");
}
if (provider !== normalizedProvider) {
throw new AIError.ConfigurationError(
"OMP_AUTH_BROKER_ACCOUNT_POOL_FILE contains a provider id with surrounding whitespace",
);
}
if (!Array.isArray(value)) {
throw new AIError.ConfigurationError(
`OMP_AUTH_BROKER_ACCOUNT_POOL_FILE entry for ${provider} must be an array of identity keys`,
);
}View on GitHub (pinned to 9690622007)
Solutions
- Reshape the file to a top-level JSON object: { "provider-id": ["identity-key", ...] }.
- If your data is currently an array, convert it (e.g. Object.fromEntries(entries.map(e => [e.provider, e.identities]))).
- Check the generating script/writer to ensure it serializes the object form, and validate with `jq 'type' file` — it must print "object".
- If the file is a placeholder, remove the env var until a real pool file is produced.
Example fix
// before (account-pool.json)
["openai:acc1", "anthropic:acc2"]
// after
{
"openai": ["acc1"],
"anthropic": ["acc2"]
} Defensive patterns
Strategy: validation
Validate before calling
function validatePoolFileShape(text: string): void {
const parsed = JSON.parse(text);
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
throw new Error("pool file must be a top-level JSON object keyed by provider");
}
} Type guard
function isProviderPool(v: unknown): v is Record<string, unknown> {
return v !== null && typeof v === "object" && !Array.isArray(v);
} Try / catch
try {
const pool = await loadAuthBrokerAccountPool();
} catch (err) {
if (err instanceof AIError.ConfigurationError && err.message.includes("must contain a JSON object")) {
logger.error("pool file top-level shape invalid; expected object keyed by provider");
} else throw err;
} Prevention
- Keep a canonical example pool file in your repo and validate against it in CI.
- Have writer scripts assert the serialized top level is an object before writing.
- Check with `jq 'type' pool.json` — must output "object".
- Never hand-edit the pool file without re-running your JSON validation step.
When it happens
Trigger: OMP_AUTH_BROKER_ACCOUNT_POOL_FILE points to a file whose top-level JSON is null, a scalar ("abc", 42, true), or an array (e.g. a JSON list of accounts instead of an object keyed by provider).
Common situations: Pool file written by a script exporting an array of provider entries instead of an object; hand-written placeholder containing null or "todo"; a tool that serialized a Map as an array of [key, value] pairs.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- OMP_AUTH_BROKER_ACCOUNT_POOL_FILE entry for ${provider} must
- OMP_AUTH_BROKER_ACCOUNT_POOL_FILE contains an empty provider
- Auth broker response failed schema validation
- Unable to read OMP_AUTH_BROKER_ACCOUNT_POOL_FILE at ${filePa
- OMP_AUTH_BROKER_ACCOUNT_POOL_FILE contains a provider id wit
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/2bb0dea876601238.
Report an issue: GitHub.