xai-org/x-algorithm · error · SemanticCheckFailure
cannot find class %s
Error message
cannot find class %s
What it means
TypeCompiler.getTypeFromClassName loads a class by name through ClassCache to build a thrift Type. Any loading failure (ClassNotFoundException and friends) is wrapped as SemanticCheckFailure 'cannot find class %s'.
Source
Thrown at botmaker/src/java/com/twitter/botmaker/compiler/types/TypeCompiler.java:99
}
ImmutableList.Builder<Type> paramTypesBuilder = ImmutableList.builder();
for (int i = 1; i < tree.getChildCount(); i++) {
paramTypesBuilder.add(getType(tree.getChild(i), context));
}
return Type.of(info.getFirst(), paramTypesBuilder.build());
}
public static Optional<Type> getPrimitiveType(String name) {
return Type.getPrimitiveTypeFromName(name);
}
public static Type getTypeFromClassName(String className) throws SemanticCheckFailure {
Class<?> clazz;
try {
clazz = ClassCache.forName(className);
} catch (Exception e) {
throw new SemanticCheckFailure(
String.format("cannot find class %s", className)
);
}
if (TBase.class.isAssignableFrom(clazz)) {
return Type.thriftOf((Class<? extends TBase>) clazz);
} else if (ThriftStruct.class.isAssignableFrom(clazz)) {
return Type.thriftStructOf((Class<? extends ThriftStruct>) clazz);
} else {
throw new SemanticCheckFailure(
String.format("class has to be either a TBase or ThriftStruct: %s.", className)
);
}
}
}
View on GitHub (pinned to 24c60942c5)
Solutions
- Verify the fully-qualified name matches the generated class exactly
- Add the thrift-generated jar containing the class to the botmaker classpath
- Check shading/relocation rules and classloader parentage
- Rebuild rules against the current schema's package names
Example fix
// before
Type t = TypeCompiler.getTypeFromClassName("com.acme.oldpkg.User");
// after
Type t = TypeCompiler.getTypeFromClassName("com.acme.newpkg.User"); Defensive patterns
Strategy: validation
Validate before calling
try { ClassCache.forName(className); } catch (Exception e) {
throw new IllegalArgumentException("class not on classpath: " + className);
} Try / catch
catch SemanticCheckFailure 'cannot find class' and surface as deployment/classpath issue with the FQN
Prevention
- Ship thrift jars with the rules that reference them
- Startup smoke-test loading every referenced class
When it happens
Trigger: Referring to a fully-qualified thrift struct class in a rule/binding when the class is absent from the classpath — wrong package, typo in FQN, missing jar, or classloader isolation.
Common situations: Deploying rules without the thrift jar containing the struct; renaming the thrift package in the IDL; shading/relocation changing package names; separate classloader environments (app servers) where ClassCache can't see the class.
Related errors
- cannot find class %s
- Cannot load ThriftStruct Codec for %s: $s
- class to be imported has to be either a TBase or ThriftStruc
- Thriftjava objects are not supported in strato JSON
- Failed to create serializer for ThriftStruct %s: %s
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/bd23820e9624eddd.
Report an issue: GitHub.