{"record":{"id":"8a83031d20b61957","repo":"apache/shenyu","slug":"grpc-client-must-config-the-contextpath-ipandport","errorCode":null,"errorMessage":"grpc client must config the contextPath, ipAndPort","messagePattern":"grpc client must config the contextPath, ipAndPort","errorType":"exception","errorClass":"ShenyuClientIllegalArgumentException","httpStatus":null,"severity":"critical","filePath":"shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/GrpcClientEventListener.java","lineNumber":72,"sourceCode":"import java.util.stream.Collectors;\n\n/**\n * The type Shenyu grpc client event listener.\n */\npublic class GrpcClientEventListener extends AbstractContextRefreshedEventListener<BindableService, ShenyuGrpcClient> {\n    \n    private final List<ServerServiceDefinition> serviceDefinitions = Lists.newArrayList();\n    \n    /**\n     * Instantiates a new Shenyu client bean post processor.\n     *\n     * @param clientConfig the shenyu grpc client config\n     * @param shenyuClientRegisterRepository the shenyuClientRegisterRepository\n     */\n    public GrpcClientEventListener(final ShenyuClientConfig clientConfig, final ShenyuClientRegisterRepository shenyuClientRegisterRepository) {\n        super(clientConfig, shenyuClientRegisterRepository);\n        if (StringUtils.isAnyBlank(getContextPath(), getIpAndPort(), getPort())) {\n            throw new ShenyuClientIllegalArgumentException(\"grpc client must config the contextPath, ipAndPort\");\n        }\n    }\n\n    @Override\n    protected Sextet<String[], String, String, ApiHttpMethodEnum[], RpcTypeEnum, String> buildApiDocSextet(final Method method, final Annotation annotation, final Map<String, BindableService> beans) {\n        ShenyuGrpcClient shenyuGrpcClient = AnnotatedElementUtils.findMergedAnnotation(method, ShenyuGrpcClient.class);\n        if (Objects.isNull(shenyuGrpcClient)) {\n            return null;\n        }\n        String produce = ShenyuClientConstants.MEDIA_TYPE_ALL_VALUE;\n        String consume = ShenyuClientConstants.MEDIA_TYPE_ALL_VALUE;\n        String[] values = new String[]{shenyuGrpcClient.value()};\n        ApiHttpMethodEnum[] apiHttpMethodEnums = new ApiHttpMethodEnum[]{ApiHttpMethodEnum.NOT_HTTP};\n        String version = \"v0.01\";\n        return Sextet.with(values, consume, produce, apiHttpMethodEnums, RpcTypeEnum.GRPC, version);\n    }\n\n    @Override","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-client/shenyu-client-grpc/src/main/java/org/apache/shenyu/client/grpc/GrpcClientEventListener.java#L54-L90","documentation":"GrpcClientEventListener's constructor validates that the ShenYu gRPC client configuration provides contextPath, ipAndPort, and port. If any of these is blank, the listener cannot build API registrations, so it throws ShenyuClientIllegalArgumentException at bean construction time, failing application startup.","triggerScenarios":"Constructing/starting the gRPC client (Spring bean creation) when shenyu.client.grpc props lack contextPath, ipAndPort, or port — e.g. empty or missing keys in application.yml.","commonSituations":"Copy-pasting config from another client type (http, dubbo) that uses different prop names; forgetting the props block entirely; yaml indentation errors making values null.","solutions":["Add contextPath, ipAndPort, and port under shenyu.client.grpc.props in application.yml","Verify the config is bound: check ShenyuClientConfig props map keys match exactly","Check yaml indentation so values are not parsed as null","Start from the official shenyu-examples grpc config as a template"],"exampleFix":"// before\nshenyu:\n  client:\n    grpc:\n      props: {}\n// after\nshenyu:\n  client:\n    grpc:\n      props:\n        contextPath: /grpc\n        ipAndPort: 127.0.0.1:8080\n        port: 8080","handlingStrategy":"validation","validationCode":"Map<String, String> props = clientConfig.getGrpc().getProps();\nif (props == null || props.values().stream().anyMatch(StringUtils::isBlank)\n        || !props.keySet().containsAll(List.of(\"contextPath\", \"ipAndPort\", \"port\"))) {\n    throw new IllegalStateException(\"shenyu.client.grpc props must set contextPath, ipAndPort, port\");\n}","typeGuard":null,"tryCatchPattern":"try { new GrpcClientEventListener(clientConfig, repository); }\ncatch (ShenyuClientIllegalArgumentException e) {\n    throw new IllegalStateException(\"Fix shenyu.client.grpc config: \" + e.getMessage());\n}","preventionTips":["Use the shenyu-examples grpc yml as a template","Fail fast with a startup config check","Watch for yaml indentation issues that null out props"],"tags":["grpc","configuration","startup"],"backgroundTag":"missing-required-config-field","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"}