earendil-works/pi · error
Failed to read trust store
Error message
Failed to read trust store ${path}: ${message} What it means
IO error wrapper in readTrustFile: the trust-store JSON file at the given path exists but JSON.parse failed (after BOM stripping). The underlying parse error message is included; the file is corrupted, truncated, or not valid JSON.
Solutions
- Fix or re-create the trust store file as valid JSON (object of path -> true/false/null)
- Delete the corrupted file to start with an empty trust store
- Restore the file from a backup
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/coding-agent/src/core/trust-manager.ts:108 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/827285f977f3756e.
Report an issue: GitHub.
Appendix: source
Thrown at packages/coding-agent/src/core/trust-manager.ts:108
savedPath: trustPath,
});
if (options?.includeSessionOnly) {
trustOptions.push({ label: "Do not trust (this session only)", trusted: false, updates: [] });
}
return trustOptions;
}
function readTrustFile(path: string): TrustFile {
if (!existsSync(path)) {
return {};
}
let parsed: unknown;
try {
parsed = JSON.parse(stripBom(readFileSync(path, "utf-8")));
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
throw new Error(`Failed to read trust store ${path}: ${message}`);
}
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
throw new Error(`Invalid trust store ${path}: expected an object`);
}
const data: TrustFile = {};
for (const [key, value] of Object.entries(parsed)) {
if (value !== true && value !== false && value !== null) {
throw new Error(`Invalid trust store ${path}: value for ${JSON.stringify(key)} must be true, false, or null`);
}
data[key] = value;
}
return data;
}
function writeTrustFile(path: string, data: TrustFile): void {
const sorted: TrustFile = {};View on GitHub (pinned to 4af9d21d3b)