affaan-m/ECC · error · Error
Canonical session snapshot requires ${fieldPath} to be a str
Error message
Canonical session snapshot requires ${fieldPath} to be a string What it means
Thrown by the ensureStringAllowEmpty helper when a field must be a string but is permitted to be empty, yet the value is not a string at all (number, object, etc.). Currently applied to workers[i].intent.objective, which may be an empty objective string but must still be a string.
Source
Thrown at scripts/lib/session-adapters/canonical-session.js:41
if (typeof context !== 'string' || context.trim().length === 0) {
return [];
}
return context
.split('\n')
.map(line => line.trim())
.filter(Boolean);
}
function ensureString(value, fieldPath) {
if (typeof value !== 'string' || value.length === 0) {
throw new Error(`Canonical session snapshot requires ${fieldPath} to be a non-empty string`);
}
}
function ensureStringAllowEmpty(value, fieldPath) {
if (typeof value !== 'string') {
throw new Error(`Canonical session snapshot requires ${fieldPath} to be a string`);
}
}
function ensureOptionalString(value, fieldPath) {
if (value !== null && value !== undefined && typeof value !== 'string') {
throw new Error(`Canonical session snapshot requires ${fieldPath} to be a string or null`);
}
}
function ensureBoolean(value, fieldPath) {
if (typeof value !== 'boolean') {
throw new Error(`Canonical session snapshot requires ${fieldPath} to be a boolean`);
}
}
function ensureArrayOfStrings(value, fieldPath) {
if (!Array.isArray(value) || value.some(item => typeof item !== 'string')) {
throw new Error(`Canonical session snapshot requires ${fieldPath} to be an array of strings`);View on GitHub (pinned to 01e15490f0)
Solutions
- Coerce the objective to a string when building the worker: String(worker.task.objective || '').
- Ensure the source session always provides objective as a string (default to '' if absent).
- Validate the worker shape with a fixture before persisting.
Example fix
// before
intent: { objective: worker.task.objective, ... } // task.objective is undefined
// after
intent: { objective: typeof worker.task.objective === 'string' ? worker.task.objective : '', ... } Defensive patterns
Strategy: validation
Validate before calling
// Coerce objective to a string (empty allowed) before building the worker. const objective = typeof raw.objective === 'string' ? raw.objective : '';
Type guard
function isStringAllowEmpty(v) { return typeof v === 'string'; } Prevention
- Coerce source fields with String(x || '') when building intent.objective.
- Keep the objective a flat string, not a structured object.
When it happens
Trigger: A worker's intent.objective is set to null, undefined, a number, or an object instead of a string. For example, an adapter assigning objective: worker.task.objective where task.objective is missing and resolves to a non-string.
Common situations: An adapter normalizing a session whose task.objective was never set; a downstream transform that converted the objective to a structured object; a test fixture passing a number for the objective.
Related errors
- Canonical session snapshot requires ${fieldPath} to be a non
- Canonical session snapshot requires ${fieldPath} to be a str
- Canonical session snapshot requires ${fieldPath} to be a boo
- Canonical session snapshot requires ${fieldPath} to be an ar
- Canonical session snapshot requires ${fieldPath} to be a non
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/e5513cca8ebc47df.
Report an issue: GitHub.