discourse/discourse · error · Error
blockCondition: "validate" must be a function, got
Error message
blockCondition: "validate" must be a function, got ${typeof validateFn}. What it means
Decoration-time type validation in blockCondition: when a `validate` key is present in the config it must be a custom validation function, but a value of another type was supplied. The faulty input is `config.validate`.
Solutions
- Pass an actual function as `validate`, e.g. `validate: (args) => ...`
- Remove the validate key if no custom validation is needed
- Check that the function reference is not undefined due to a bad import
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at frontend/discourse/app/blocks/conditions/decorator.ts:208 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/619752d12bf344e5.
Report an issue: GitHub.
Appendix: source
Thrown at frontend/discourse/app/blocks/conditions/decorator.ts:208
`blockCondition: unknown config key(s): ${suggestions}. ` +
`Valid keys are: ${VALID_CONFIG_KEYS.join(", ")}.`
);
}
// Validate args schema at decoration time (catches schema definition errors)
if (argsSchema && typeof argsSchema === "object") {
validateConditionArgsSchema(argsSchema, type);
}
// Validate constraints schema at decoration time
if (constraints) {
// Constraints reference args schema - validate they're compatible
validateConstraintsSchema(constraints, argsSchema, `Condition "${type}"`);
}
// Validate that validate is a function if provided
if (validateFn !== undefined && typeof validateFn !== "function") {
throw new Error(
`blockCondition: "validate" must be a function, got ${typeof validateFn}.`
);
}
// Freeze schema and compute derived validArgKeys
const frozenSchema: Readonly<Record<string, ArgSchema>> = Object.freeze({
...argsSchema,
});
const frozenConstraints: Readonly<BlockConstraints> | undefined = constraints
? Object.freeze({ ...constraints })
: undefined;
const argKeys: readonly string[] = Object.freeze(Object.keys(argsSchema));
const allKeys: readonly string[] =
sourceType !== "none" ? Object.freeze([...argKeys, "source"]) : argKeys;
return (TargetClass) => {
// Validate that the class extends BlockCondition
if (!(TargetClass.prototype instanceof BlockCondition)) {View on GitHub (pinned to 1b2d7253e8)