{"record":{"id":"5be20a2b8c6773af","repo":"apache/skywalking","slug":"illegal-service-instance-relation-entity-id","errorCode":null,"errorMessage":"Illegal Service Instance Relation entity id","messagePattern":"Illegal Service Instance Relation entity id","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/IDManager.java","lineNumber":178,"sourceCode":"        }\n\n        /**\n         * @return encoded instance hierarchy relation id\n         */\n        public static String buildInstanceHierarchyRelationId(InstanceHierarchyRelationDefine define) {\n            return define.instanceId + Const.SERVICE_ID_CONNECTOR + define.serviceLayer.value() +\n                Const.RELATION_ID_CONNECTOR +\n                define.relatedInstanceId + Const.SERVICE_ID_CONNECTOR + define.relatedServiceLayer.value();\n        }\n\n        /**\n         * @return service instance relation ID object decoded from {@link #buildRelationId(ServiceInstanceRelationDefine)}\n         * result\n         */\n        public static ServiceInstanceID.ServiceInstanceRelationDefine analysisRelationId(String entityId) {\n            String[] parts = entityId.split(Const.RELATION_ID_PARSER_SPLIT);\n            if (parts.length != 2) {\n                throw new RuntimeException(\"Illegal Service Instance Relation entity id\");\n            }\n            return new ServiceInstanceID.ServiceInstanceRelationDefine(parts[0], parts[1]);\n        }\n\n        @RequiredArgsConstructor\n        @Getter\n        public static class InstanceIDDefinition {\n            /**\n             * Built by {@link ServiceID#buildId(String, boolean)}\n             */\n            private final String serviceId;\n            private final String name;\n        }\n\n        @RequiredArgsConstructor\n        @Getter\n        @EqualsAndHashCode\n        public static class ServiceInstanceRelationDefine {","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/IDManager.java#L160-L196","documentation":"RuntimeException thrown by IDManager.ServiceInstanceID.analysisRelationId(String) when a service-instance relation entity id does not split into exactly 2 parts. Valid ids come from buildRelationId as instanceId + RELATION_ID_CONNECTOR + relatedInstanceId; anything with a different segment count is rejected. Note the parallel hierarchy builder (for instance layers) emits 4-segment ids that this method cannot parse.","triggerScenarios":"Feeding a hierarchy-format instance relation id (instance + layer + connector + related instance + layer) into analysisRelationId; hand-built relation strings with wrong connector count; null or empty input; corrupted storage values.","commonSituations":"New code paths distinguishing layered vs plain instance relations picking the wrong parser; query/GraphQL layer code re-splitting ids manually then passing remnants downstream; data written by a divergent fork.","solutions":["Use ServiceInstanceID.buildRelationId(...) to create ids and only decode its output with analysisRelationId","Choose a dedicated parser for 4-segment hierarchy ids rather than this method","Log the offending entityId (it is not in the message — add it at the call site or inspect the argument) and audit its producer","Add a defensive parts.length check before calling in integration code"],"exampleFix":"// before\nString[] p = entityId.split(\"\\\\.\");\nIDManager.ServiceInstanceID.analysisRelationId(p[0] + \".\" + p[1]); // mangled id\n\n// after\nServiceInstanceRelationDefine def =\n    IDManager.ServiceInstanceID.analysisRelationId(entityId); // pass the id through untouched","handlingStrategy":"type-guard","validationCode":"if (entityId == null || entityId.split(\"\\\\.\").length != 2) {\n    throw new IllegalArgumentException(\"Not a plain instance-relation id (4 segments means hierarchy format): \" + entityId);\n}","typeGuard":"boolean isPlainInstanceRelationId(String id) {\n    return id != null && id.split(\"\\\\.\").length == 2;\n}","tryCatchPattern":"try {\n    ServiceInstanceRelationDefine def = IDManager.ServiceInstanceID.analysisRelationId(entityId);\n} catch (RuntimeException e) {\n    LOGGER.warn(\"Dropping malformed instance relation id: {}\", entityId, e);\n}","preventionTips":["Route relation ids by their builder (plain vs hierarchy) — never guess by try/catch alone","Audit custom query plugins that re-split ids and pass fragments onward","Capture the entityId in your own logs since this exception omits it"],"tags":["id-management","data-corruption","parsing","oap-server"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}