xai-org/x-algorithm · error · SemanticCheckFailure
The mock for function %s is not defined.
Error message
The mock for function %s is not defined.
What it means
When compiling in test/mock mode, createMock is asked to substitute a target class; if that class is not among the functions registered as mockable (funcs), compilation fails with this error. It guards against mocking unknown targets.
Source
Thrown at botmaker/src/java/com/twitter/botmaker/compiler/CompilerContext.java:471
return target;
}
if (target instanceof ThriftStructOperator) {
return target;
}
String nls = target.getPackageName();
for (String filter : packages) {
if (nls.startsWith(filter)) {
return target;
}
}
if (funcs.contains(className)) {
return target;
}
throw new SemanticCheckFailure(
String.format("The mock for function %s is not defined.", target.getClassName())
);
}
}
}
View on GitHub (pinned to 24c60942c5)
Solutions
- Verify the mock target class name matches the registered mockable function exactly
- Register the function in the mock set used by the test CompilerContext
- Use the same naming convention (simple vs FQCN) as the registration code
Defensive patterns
Strategy: validation
Validate before calling
if (!funcs.contains(targetClassName)) throw new IllegalArgumentException("No mock registered for " + targetClassName); Try / catch
catch (SemanticCheckFailure e) { /* verify mock registry contains the exact class name */ } Prevention
- Populate the mock function set in test setup before compiling
- Keep mock names in sync with renames via a shared constants file
When it happens
Trigger: Compiling an expression with a mock directive naming a function/class that was never registered in the mock function set, or a typo in the class name of the mock target.
Common situations: Writing test mocks for functions that were renamed; the mock registry not being populated (missing setup in test harness); using the fully-qualified vs simple class name inconsistently.
Related errors
- Mock function expects either 1 or 3 arguments but %d receive
- MockPass function expects either 1 arguments but %d received
- MockPassAll function expects 1 arguments but %d received
- TestRun function expects 1 arguments but %d received
- Function '%s' does not exist
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/2dd8824dc04eab14.
Report an issue: GitHub.