{"record":{"id":"662e3a5187413422","repo":"apache/shenyu","slug":"either-name-or-value-must-be-provided-in-feignclient","errorCode":null,"errorMessage":"Either 'name' or 'value' must be provided in @FeignClient","messagePattern":"Either 'name' or 'value' must be provided in @FeignClient","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"shenyu-sdk/shenyu-sdk-feign/src/main/java/org/apache/shenyu/sdk/feign/ShenyuClientsRegistrar.java","lineNumber":462,"sourceCode":"    private String getClientName(final Map<String, Object> client) {\n        if (Objects.isNull(client)) {\n            return null;\n        }\n        String value = (String) client.get(\"contextId\");\n        if (!StringUtils.hasText(value)) {\n            value = (String) client.get(\"value\");\n        }\n        if (!StringUtils.hasText(value)) {\n            value = (String) client.get(\"name\");\n        }\n        if (!StringUtils.hasText(value)) {\n            value = (String) client.get(\"serviceId\");\n        }\n        if (StringUtils.hasText(value)) {\n            return value;\n        }\n\n        throw new IllegalStateException(\n            \"Either 'name' or 'value' must be provided in @\" + FeignClient.class.getSimpleName());\n    }\n\n    private void registerClientConfiguration(final BeanDefinitionRegistry registry, final Object name, final Object configuration) {\n        BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FeignClientSpecification.class);\n        builder.addConstructorArgValue(name);\n        builder.addConstructorArgValue(configuration);\n        registry.registerBeanDefinition(name + \".\" + FeignClientSpecification.class.getSimpleName(),\n            builder.getBeanDefinition());\n    }\n\n    private boolean isClientRefreshEnabled() {\n        return environment.getProperty(\"feign.client.refresh-enabled\", Boolean.class, false);\n    }\n\n}\n","sourceCodeStart":444,"sourceCodeEnd":479,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-sdk/shenyu-sdk-feign/src/main/java/org/apache/shenyu/sdk/feign/ShenyuClientsRegistrar.java#L444-L479","documentation":"getClientName() derives the logical service name for a @FeignClient-annotated interface. It checks name, then value, then serviceId attributes; if none contains text it throws IllegalStateException because the SDK cannot register or route the client without a name. The annotation contract requires at least one of these attributes.","triggerScenarios":"Declaring @FeignClient (or Shenyu's equivalent) with no name/value/serviceId, or with only an empty string, e.g. @FeignClient(url = \"http://localhost:9195\") or @FeignClient(\"\").","commonSituations":"Copy-pasting an interface and deleting the name attribute; specifying only contextId or url and assuming name is optional; refactoring that moved the name to a constant which was left blank.","solutions":["Add a name to the annotation: @FeignClient(name = \"order-service\").","Alternatively set value or serviceId to a non-empty string — getClientName accepts any of the three.","If the name should come from configuration, use @FeignClient(name = \"${client.order.name}\") and define that property.","Audit all @FeignClient interfaces at startup (e.g. a unit test scanning the package) to catch missing names early."],"exampleFix":"// before\n@FeignClient(url = \"http://localhost:9195\")\npublic interface OrderApi { }\n// after\n@FeignClient(name = \"order-service\", url = \"http://localhost:9195\")\npublic interface OrderApi { }","handlingStrategy":"validation","validationCode":"FeignClient a = clazz.getAnnotation(FeignClient.class);\nboolean named = a != null && Stream.of(a.name(), a.value(), a.serviceId()).anyMatch(StringUtils::hasText);\nif (!named) throw new IllegalStateException(\"@FeignClient on \" + clazz.getName() + \" needs name/value/serviceId\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make name a mandatory part of your client-interface code review checklist.","Derive names from constants or configuration rather than hand-editing each annotation.","Scan the client package in a unit test to assert every annotation has a name."],"tags":["annotation","missing-attribute","startup"],"backgroundTag":"missing-required-argument","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"}