earendil-works/pi · error · Error
Failed to read auth.json: ${error instanceof Error ? error.m
Error message
Failed to read auth.json: ${error instanceof Error ? error.message : String(error)} What it means
Error "Failed to read auth.json: ${error instanceof Error ? error.message : String(error)}" thrown in earendil-works/pi.
Source
Thrown at packages/coding-agent/src/core/auth-storage.ts:222
private readonly authPath: string;
private data: AuthStorageData | undefined;
constructor(authPath: string = join(getAgentDir(), "auth.json")) {
this.authPath = normalizePath(authPath);
}
private load(): AuthStorageData {
if (this.data) return this.data;
let parsed: unknown;
try {
parsed = JSON.parse(stripBom(readFileSync(this.authPath, "utf-8")));
} catch (error) {
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
this.data = {};
return this.data;
}
throw new Error(`Failed to read auth.json: ${error instanceof Error ? error.message : String(error)}`);
}
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
throw new Error("Invalid auth.json: expected an object");
}
for (const [providerId, credential] of Object.entries(parsed)) {
if (typeof credential !== "object" || credential === null || Array.isArray(credential)) {
throw new Error(`Invalid auth.json credential for provider "${providerId}"`);
}
const value = credential as Record<string, unknown>;
if (value.type === "api_key") {
const validKey = value.key === undefined || typeof value.key === "string";
const validEnv =
value.env === undefined ||
(typeof value.env === "object" &&
value.env !== null &&
!Array.isArray(value.env) &&
Object.values(value.env).every((entry) => typeof entry === "string"));View on GitHub (pinned to 4af9d21d3b)
When it happens
Trigger: Thrown at packages/coding-agent/src/core/auth-storage.ts:222 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/3d16dc40ee785268.
Report an issue: GitHub.