can1357/oh-my-pi · error · AIError.ConfigurationError
Unable to read OMP_AUTH_BROKER_ACCOUNT_POOL_FILE at ${filePa
Error message
Unable to read OMP_AUTH_BROKER_ACCOUNT_POOL_FILE at ${filePath} What it means
loadAuthBrokerAccountPool reads the account pool file pointed to by OMP_AUTH_BROKER_ACCOUNT_POOL_FILE. If Bun.file(filePath).json() fails for any reason — missing file, permission denied, invalid JSON, unreadable path — it rethrows as AIError.ConfigurationError with the path embedded and the original error as cause. The library treats an unreadable pool file as fatal configuration rather than silently disabling the pool, because a partially-working auth broker setup is worse than a clear startup failure.
Source
Thrown at packages/ai/src/auth-broker/discover.ts:126
return { url, token };
} catch (err) {
if (isEnoent(err)) continue;
logger.warn("auth-broker config unreadable", { path: configPath, error: String(err) });
return {};
}
}
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",
);
}View on GitHub (pinned to 9690622007)
Solutions
- Verify the file exists and is readable: `cat "$OMP_AUTH_BROKER_ACCOUNT_POOL_FILE" > /dev/null && echo ok` (or ls -l the path).
- Validate the file is well-formed JSON: `jq . "$OMP_AUTH_BROKER_ACCOUNT_POOL_FILE"` and fix any parse errors.
- If using a relative path, switch to an absolute path so the process's cwd cannot change the resolution.
- If the pool is optional for your setup, unset OMP_AUTH_BROKER_ACCOUNT_POOL_FILE entirely (empty/undefined disables the pool).
- Inspect the `cause` property of the thrown ConfigurationError to distinguish ENOENT vs EACCES vs JSON parse failure.
Example fix
// before export OMP_AUTH_BROKER_ACCOUNT_POOL_FILE=./pool.json # relative, file may not exist // after export OMP_AUTH_BROKER_ACCOUNT_POOL_FILE=/etc/omp/account-pool.json # absolute, verified with jq
Defensive patterns
Strategy: try-catch
Validate before calling
// before calling the API
const filePath = process.env.OMP_AUTH_BROKER_ACCOUNT_POOL_FILE?.trim();
if (filePath) {
const file = Bun.file(filePath);
if (!(await file.exists())) throw new Error(`pool file missing: ${filePath}`);
JSON.parse(await file.text()); // throws SyntaxError with details if not valid JSON
} Type guard
function isReadableFile(p: string): boolean {
try {
return fs.statSync(p).isFile();
} catch {
return false;
}
} Try / catch
try {
const pool = await loadAuthBrokerAccountPool();
} catch (err) {
if (err instanceof AIError.ConfigurationError && err.message.includes("Unable to read OMP_AUTH_BROKER_ACCOUNT_POOL_FILE")) {
logger.error("account pool file unreadable", { cause: err.cause });
// fall back to no pool or abort startup
} else throw err;
} Prevention
- Use absolute paths for OMP_AUTH_BROKER_ACCOUNT_POOL_FILE so cwd changes cannot break resolution.
- Validate the file with `jq . "$VAR"` at deploy time before the service starts.
- In provisioning scripts, fail fast if the pool file is missing after creation.
- Remember: unsetting the env var cleanly disables the pool — don't leave it pointing at a removed file.
When it happens
Trigger: Calling loadAuthBrokerAccountPool (directly or via accountPool) when OMP_AUTH_BROKER_ACCOUNT_POOL_FILE is set to a path that does not exist, points to a directory, has wrong permissions, or contains non-JSON content.
Common situations: Typo in the file path; file deleted or moved after export; pool file generated by another tool that wrote invalid JSON (trailing commas, truncation); relative path resolved from a different working directory in a daemon/systemd context; read permissions changed by a security policy.
Related errors
- OMP_AUTH_BROKER_ACCOUNT_POOL_FILE must contain a JSON object
- OMP_AUTH_BROKER_ACCOUNT_POOL_FILE contains an empty provider
- OMP_AUTH_BROKER_ACCOUNT_POOL_FILE entry for ${provider} must
- Cannot change working directory to ${parsed.cwd}: ${reason}.
- Plugin source directory does not exist: "${resolved}"
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/86a25c422c1c0a26.
Report an issue: GitHub.