{"record":{"id":"2dd8824dc04eab14","repo":"xai-org/x-algorithm","slug":"the-mock-for-function-s-is-not-defined","errorCode":null,"errorMessage":"The mock for function %s is not defined.","messagePattern":"The mock for function (.+?) is not defined\\.","errorType":"validation","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/CompilerContext.java","lineNumber":471,"sourceCode":"        return target;\n      }\n\n      if (target instanceof ThriftStructOperator) {\n        return target;\n      }\n\n      String nls = target.getPackageName();\n      for (String filter : packages) {\n        if (nls.startsWith(filter)) {\n          return target;\n        }\n      }\n\n      if (funcs.contains(className)) {\n        return target;\n      }\n\n      throw new SemanticCheckFailure(\n          String.format(\"The mock for function %s is not defined.\", target.getClassName())\n      );\n    }\n  }\n}\n\n\n","sourceCodeStart":453,"sourceCodeEnd":479,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/CompilerContext.java#L453-L479","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!funcs.contains(targetClassName)) throw new IllegalArgumentException(\"No mock registered for \" + targetClassName);","typeGuard":null,"tryCatchPattern":"catch (SemanticCheckFailure e) { /* verify mock registry contains the exact class name */ }","preventionTips":["Populate the mock function set in test setup before compiling","Keep mock names in sync with renames via a shared constants file"],"tags":["botmaker","mock","testing","name-resolution"],"backgroundTag":"unregistered-mock-target","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}