discourse/discourse · error · BlockError
${typeError.message}
Error message
${typeError.message} What it means
Blocks schema validation: the argument's value was provided and its name is valid, but validateArgValue found a type/schema mismatch — the wrapped message is the underlying type error (wrong type, failed enum/pattern, or out-of-range value per the ArgSchema). The BlockError carries the sub-path from that validation.
Solutions
- Read the inner message for the specific constraint, then coerce or change the value at the call site to the declared type.
- If the declared type is wrong, update the ArgSchema in the @block decorator to match reality.
- For enum/pattern constraints, use one of the declared values or fix the pattern.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at frontend/discourse/app/lib/blocks/-internals/validation/args.ts:1121 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of discourse/discourse@1b2d7253e8 (2026-08-26).
Data as JSON: /api/errors/227fc649e9135eb2.
Report an issue: GitHub.
Appendix: source
Thrown at frontend/discourse/app/lib/blocks/-internals/validation/args.ts:1121
);
}
}
for (const [argName, argDef] of Object.entries(schema)) {
const value = providedArgs[argName];
// 2. Check required args
if (argDef.required && value === undefined) {
throw new BlockError(`missing required ${pathPrefix}.${argName}.`, {
path: `${pathPrefix}.${argName}`,
});
}
// 3. Validate type if value is provided
if (value !== undefined) {
const typeError = validateArgValue(value, argDef, argName, options);
if (typeError) {
throw new BlockError(typeError.message, {
path: `${pathPrefix}.${typeError.path}`,
});
}
}
}
}
View on GitHub (pinned to 1b2d7253e8)