{"record":{"id":"3a20e9bc3d3e9955","repo":"apache/skywalking","slug":"cannot-resolve-index-access-on-simplename-in-def","errorCode":null,"errorMessage":"Cannot resolve index access on {simpleName} in def variable chain","messagePattern":"Cannot resolve index access on (.+?) in def variable chain","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":345,"sourceCode":"                    } else {\n                        prevExpr = \"(\" + prevExpr + \" == null ? null : \"\n                            + prevExpr + \".\" + getter.getName() + \"())\";\n                        currentType = returnType;\n                        canBeNull = true;\n                    }\n                } else {\n                    prevExpr = prevExpr + \".\" + getter.getName() + \"()\";\n                    currentType = returnType;\n                    canBeNull = !returnType.isPrimitive();\n                }\n            } else if (seg instanceof LALScriptModel.IndexSegment) {\n                final int index = ((LALScriptModel.IndexSegment) seg).getIndex();\n                // Try get(int) method (e.g., JsonArray.get(int))\n                Method getMethod = null;\n                try {\n                    getMethod = currentType.getMethod(\"get\", int.class);\n                } catch (NoSuchMethodException e) {\n                    throw new IllegalArgumentException(\n                        \"Cannot resolve index access on \"\n                            + currentType.getSimpleName()\n                            + \" in def variable chain\");\n                }\n                final Class<?> returnType = getMethod.getReturnType();\n                if (canBeNull) {\n                    prevExpr = \"(\" + prevExpr + \" == null ? null : \"\n                        + prevExpr + \".get(\" + index + \"))\";\n                } else {\n                    prevExpr = prevExpr + \".get(\" + index + \")\";\n                }\n                currentType = returnType;\n                canBeNull = true;\n            }\n        }\n\n        genCtx.lastResolvedType = currentType;\n        sb.append(prevExpr);","sourceCodeStart":327,"sourceCodeEnd":363,"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#L327-L363","documentation":"AbstractLogRecord.id() always throws UnexpectedException. AbstractLogRecord is the shared column/schema superclass for log records; it has no single natural key, so every concrete subclass (e.g. the default log record built by LogBuilder implementations) must override id() to produce its StorageID. Calling the inherited method means the subclass forgot (or was constructed before being fully populated).","triggerScenarios":"An instance whose runtime class does not override id() flows into storage or query code that calls record.id() — e.g. registering a custom LogBuilder that instantiates a bare subclass of AbstractLogRecord without implementing id(), or unit tests instantiating the abstract record directly.","commonSituations":"Writing a custom LAL sink / log storage implementation that reuses AbstractLogRecord; copy-pasting a record class and dropping the id() override; reflective instantiation of a log record class that was refactored.","solutions":["Override id() in the concrete record subclass to return a StorageID built from the record's identity columns (e.g. timestamp + serviceId + traceId)","If using the built-in log storage, return the stock LogRecord implementation rather than your own AbstractLogRecord subclass","Add an abstract-method-style test that fails when a new AbstractLogRecord subclass lacks id()"],"exampleFix":"// before\nclass MyLogRecord extends AbstractLogRecord { } // inherits throwing id()\n// after\nclass MyLogRecord extends AbstractLogRecord {\n    @Override\n    public StorageID id() {\n        return new StorageID()\n            .append(TIME_BUCKET, getTimeBucket())\n            .append(SERVICE_ID, getServiceId());\n    }\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean hasId = record.getClass() != AbstractLogRecord.class\n    && java.util.stream.Stream.of(record.getClass().getMethods())\n        .anyMatch(m -> m.getName().equals(\"id\") && m.getDeclaringClass() != AbstractLogRecord.class);","tryCatchPattern":"try { id = record.id(); } catch (UnexpectedException e) { throw new IllegalStateException(record.getClass() + \" must override id()\", e); }","preventionTips":["Always override id() in AbstractLogRecord subclasses","Prefer reusing the stock LogRecord class from LogBuilder"],"tags":["skywalking","oap","log","storage","subclassing"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}