{"record":{"id":"c711ab6e5c531278","repo":"affaan-m/ECC","slug":"canonical-session-snapshot-requires-fieldpath-t-c711ab","errorCode":null,"errorMessage":"Canonical session snapshot requires ${fieldPath} to be a boolean","messagePattern":"Canonical session snapshot requires (.+?) to be a boolean","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/session-adapters/canonical-session.js","lineNumber":53,"sourceCode":"    throw new Error(`Canonical session snapshot requires ${fieldPath} to be a non-empty string`);\n  }\n}\n\nfunction ensureStringAllowEmpty(value, fieldPath) {\n  if (typeof value !== 'string') {\n    throw new Error(`Canonical session snapshot requires ${fieldPath} to be a string`);\n  }\n}\n\nfunction ensureOptionalString(value, fieldPath) {\n  if (value !== null && value !== undefined && typeof value !== 'string') {\n    throw new Error(`Canonical session snapshot requires ${fieldPath} to be a string or null`);\n  }\n}\n\nfunction ensureBoolean(value, fieldPath) {\n  if (typeof value !== 'boolean') {\n    throw new Error(`Canonical session snapshot requires ${fieldPath} to be a boolean`);\n  }\n}\n\nfunction ensureArrayOfStrings(value, fieldPath) {\n  if (!Array.isArray(value) || value.some(item => typeof item !== 'string')) {\n    throw new Error(`Canonical session snapshot requires ${fieldPath} to be an array of strings`);\n  }\n}\n\nfunction ensureInteger(value, fieldPath) {\n  if (!Number.isInteger(value) || value < 0) {\n    throw new Error(`Canonical session snapshot requires ${fieldPath} to be a non-negative integer`);\n  }\n}\n\nconst STALE_THRESHOLD_MS = 5 * 60 * 1000;\n\nfunction parseUpdatedMs(updated) {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/session-adapters/canonical-session.js#L35-L71","documentation":"ensureBoolean requires the named snapshot field to be exactly a JavaScript boolean (typeof === 'boolean'). The library throws this when a boolean-flagged field (e.g. session state flags) carries a truthy number, string like \"true\", or null. Canonical snapshots use strict types so all consumers can switch on the value without coercion.","triggerScenarios":"persistCanonicalSnapshot or a normalize* adapter receives a snapshot where a boolean field holds 0/1, \"true\"/\"false\" strings, or null — typical when data round-trips through JSON config or shell output.","commonSituations":"Reading flags from CLI output or environment variables where everything is a string; YAML parsing \"yes\"/\"no\" into strings; older schema versions using 0/1 integers.","solutions":["Locate the field from ${fieldPath} and convert it to a real boolean (value === 'true', Boolean(value) as appropriate)","Fix the producer (adapter or script) to emit native booleans","Validate the raw input before constructing the snapshot object","Regenerate the snapshot with the official normalize* functions"],"exampleFix":"// before\nsnapshot.session.isFocused = 'true';\n// after\nsnapshot.session.isFocused = true;","handlingStrategy":"validation","validationCode":"const okBool = (v) => typeof v === 'boolean';","typeGuard":"const isBoolean = (v) => typeof v === 'boolean';","tryCatchPattern":"try { persistCanonicalSnapshot(s); } catch (e) { if (/to be a boolean/.test(e.message)) { /* coerce */ } else throw e; }","preventionTips":["Store native booleans only","Parse 'true'/'false' strings explicitly"],"tags":["validation","schema","type-mismatch","boolean"],"backgroundTag":"schema-validation-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}