earendil-works/pi · error
Invalid trust store : expected an object
Error message
Invalid trust store ${path}: expected an object What it means
Shape validation in readTrustFile: the trust-store JSON parsed successfully but the top-level value is not a plain object (it is an array, string, number, or null-ish after checks). The trust store must be a map of project paths to trust booleans.
Solutions
- Rewrite the file as a JSON object mapping directory paths to true/false/null
- Example: {"/path/to/project": true}
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/coding-agent/src/core/trust-manager.ts:112 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/178eb43364812025.
Report an issue: GitHub.
Appendix: source
Thrown at packages/coding-agent/src/core/trust-manager.ts:112
}
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 = {};
for (const key of Object.keys(data).sort()) {
const value = data[key];
if (value === true || value === false || value === null) {
sorted[key] = value;View on GitHub (pinned to 4af9d21d3b)