{"record":{"id":"31035cb4ce01b864","repo":"apache/shenyu","slug":"dynamic-build-jsonmarshaller-descriptor-is-fail","errorCode":null,"errorMessage":"dynamic build JsonMarshaller descriptor is fail","messagePattern":"dynamic build JsonMarshaller descriptor is fail","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"shenyu-protocol/shenyu-protocol-grpc/src/main/java/org/apache/shenyu/protocol/grpc/message/JsonMessage.java","lineNumber":77,"sourceCode":"        DescriptorProtos.DescriptorProto.Builder jsonMarshaller = DescriptorProtos.DescriptorProto.newBuilder();\n        jsonMarshaller.setName(GrpcConstants.JSON_DESCRIPTOR_PROTO_NAME);\n        jsonMarshaller.addFieldBuilder()\n                .setName(GrpcConstants.JSON_DESCRIPTOR_PROTO_FIELD_NAME)\n                .setNumber(1)\n                .setType(DescriptorProtos.FieldDescriptorProto.Type.TYPE_STRING);\n\n        // build File Descriptor Proto\n        DescriptorProtos.FileDescriptorProto.Builder fileDescriptorProtoBuilder = DescriptorProtos.FileDescriptorProto.newBuilder();\n        fileDescriptorProtoBuilder.addMessageType(jsonMarshaller);\n\n        DescriptorProtos.FileDescriptorProto fileDescriptorProto = fileDescriptorProtoBuilder.build();\n        try {\n            Descriptors.FileDescriptor fileDescriptor = Descriptors.FileDescriptor\n                    .buildFrom(fileDescriptorProto, new Descriptors.FileDescriptor[0]);\n            return fileDescriptor.findMessageTypeByName(GrpcConstants.JSON_DESCRIPTOR_PROTO_NAME);\n        } catch (Descriptors.DescriptorValidationException e) {\n            LOG.error(\"dynamic build JsonMarshaller descriptor is fail: {}\", e.getMessage());\n            throw new RuntimeException(\"dynamic build JsonMarshaller descriptor is fail\", e);\n        }\n    }\n\n    /**\n     * buildJsonMessage.\n     *\n     * @param jsonParamMap jsonParamMap\n     * @return DynamicMessageList\n     */\n    public static List<DynamicMessage> buildJsonMessageList(final Map<String, Object> jsonParamMap) {\n        ParamCheckUtils.checkParamsLength(jsonParamMap.size(), GrpcConstants.JSON_DESCRIPTOR_PROTO_FIELD_NUM);\n        JsonArray jsonParams = (JsonArray) jsonParamMap.get(GrpcConstants.JSON_DESCRIPTOR_PROTO_FIELD_NAME);\n        List<DynamicMessage> jsonMessageList = new ArrayList<>(jsonParams.size());\n        jsonParams.forEach(jsonParam -> {\n            DynamicMessage jsonMessage = buildJsonMessage(GsonUtils.getInstance().toJson(jsonParam));\n            jsonMessageList.add(jsonMessage);\n        });\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-protocol/shenyu-protocol-grpc/src/main/java/org/apache/shenyu/protocol/grpc/message/JsonMessage.java#L59-L95","documentation":"JsonMessage.jsonDescriptor builds a protobuf FileDescriptor at runtime from a generated FileDescriptorProto for the JSON message type. If Descriptors.FileDescriptor.buildFrom throws DescriptorValidationException, the dynamically constructed descriptor is invalid, and the code logs the cause and rethrows a RuntimeException with this message. This typically means the embedded proto definition is malformed or inconsistent.","triggerScenarios":"Calling JsonMessage.jsonDescriptor()/buildJsonMarshallerDescriptor when the FileDescriptorProto for GrpcConstants.JSON_DESCRIPTOR_PROTO_NAME fails validation — e.g. dependency type references not resolvable, duplicate type names, or a corrupted/modified proto descriptor resource.","commonSituations":"Mismatches between the shenyu-protocol-grpc version and the proto assets it bundles; custom builds where JSON_DESCRIPTOR_PROTO resources were modified; protobuf-java runtime version incompatibilities with descriptor features used in the generated proto.","solutions":["Read the logged DescriptorValidationException message (the 'Caused by' in the stack trace) to identify the exact invalid element, then fix the descriptor/proto resource.","Use a consistent, unmodified shenyu-protocol-grpc artifact; restore the original JSON descriptor proto resources if they were customized.","Align the protobuf-java runtime version with the one the descriptors were generated for.","Clear stale build artifacts and rebuild shenyu-protocol-grpc so descriptor resources regenerate cleanly."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return jsonDescriptor();\n} catch (RuntimeException e) {\n    if (\"dynamic build JsonMarshaller descriptor is fail\".equals(e.getMessage())) {\n        LOG.error(\"descriptor build failed; check protobuf resources/version\", e.getCause());\n    }\n    throw e;\n}","preventionTips":["Pin protobuf-java runtime to the version the descriptors were generated with.","Never hand-edit bundled descriptor proto resources.","Log DescriptorValidationException details to catch schema drift early in CI."],"tags":["grpc","protobuf","descriptor","initialization"],"backgroundTag":"protobuf-descriptor-build-failed","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}