{"record":{"id":"af96d26e7e8cf1db","repo":"apache/skywalking","slug":"def-cast-type-not-found-on-classpath-casttype","errorCode":null,"errorMessage":"def cast type not found on classpath: {castType}","messagePattern":"def cast type not found on classpath: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALDefCodegen.java","lineNumber":222,"sourceCode":"    private static Class<?> resolveDefCastType(final String castType) {\n        switch (castType) {\n            case \"String\":\n                return String.class;\n            case \"Long\":\n                return Long.class;\n            case \"Integer\":\n                return Integer.class;\n            case \"Double\":\n                return Double.class;\n            case \"Float\":\n                return Float.class;\n            case \"Boolean\":\n                return Boolean.class;\n            default:\n                try {\n                    return Class.forName(castType);\n                } catch (ClassNotFoundException e) {\n                    throw new IllegalArgumentException(\n                        \"def cast type not found on classpath: \" + castType, e);\n                }\n        }\n    }\n\n    // ==================== Def variable chain codegen ====================\n\n    /**\n     * Generates typed method-chain access on a def variable.\n     * Uses reflection to resolve each method/field call and track types.\n     *\n     * @param sb output buffer\n     * @param localVar the def variable info (java var name + resolved type)\n     * @param chain the chain segments after the variable name\n     * @param genCtx codegen context\n     */\n    static void generateDefVarChain(\n            final StringBuilder sb,","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALDefCodegen.java#L204-L240","documentation":"Thrown by TimeBucket.getTimeBucket(long, DownSampling) in the switch default branch when the Downsampling value is not one of Second/Minute/Hour/Day. DownSampling is an enum with exactly those four constants, so in unmodified code the default is unreachable — this is a defensive guard against a new enum constant being added without extending the arithmetic here.","triggerScenarios":"Adding a new constant (e.g. a month-tier downsampling) to the DownSampling enum without adding a case to this switch; reflective/serialization tricks that produce an uncached enum-like value.","commonSituations":"Forking or extending SkyWalking with new downsampling granularities; almost never seen on stock builds because the compiler prevents other values.","solutions":["If you extended DownSampling, add the corresponding packed-arithmetic case to the switch in TimeBucket.getTimeBucket","On a stock build, verify no bytecode manipulation or classpath shadowing is injecting a different DownSampling class","Audit which DownSampling value is passed (log it) to confirm it comes from the expected enum class"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"boolean supported = downsampling == DownSampling.Second || downsampling == DownSampling.Minute\n    || downsampling == DownSampling.Hour || downsampling == DownSampling.Day;","typeGuard":null,"tryCatchPattern":"catch (UnexpectedException e) { throw new IllegalStateException(\"unsupported downsampling: \" + downsampling, e); }","preventionTips":["If you extend DownSampling, update every switch in TimeBucket in the same change","Unreachable on stock builds — treat any occurrence as classpath shadowing"],"tags":["skywalking","oap","time-bucket","downsampling","defensive"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}