{"record":{"id":"ea272510daad733e","repo":"Netflix/Hystrix","slug":"hystrixcommandgroup-can-not-be-null","errorCode":null,"errorMessage":"HystrixCommandGroup can not be NULL","messagePattern":"HystrixCommandGroup can not be NULL","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java","lineNumber":188,"sourceCode":"        //Strategies from plugins\n        this.eventNotifier = HystrixPlugins.getInstance().getEventNotifier();\n        this.concurrencyStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy();\n        HystrixMetricsPublisherFactory.createOrRetrievePublisherForCommand(this.commandKey, this.commandGroup, this.metrics, this.circuitBreaker, this.properties);\n        this.executionHook = initExecutionHook(executionHook);\n\n        this.requestCache = HystrixRequestCache.getInstance(this.commandKey, this.concurrencyStrategy);\n        this.currentRequestLog = initRequestLog(this.properties.requestLogEnabled().get(), this.concurrencyStrategy);\n\n        /* fallback semaphore override if applicable */\n        this.fallbackSemaphoreOverride = fallbackSemaphore;\n\n        /* execution semaphore override if applicable */\n        this.executionSemaphoreOverride = executionSemaphore;\n    }\n\n    private static HystrixCommandGroupKey initGroupKey(final HystrixCommandGroupKey fromConstructor) {\n        if (fromConstructor == null) {\n            throw new IllegalStateException(\"HystrixCommandGroup can not be NULL\");\n        } else {\n            return fromConstructor;\n        }\n    }\n\n    private static HystrixCommandKey initCommandKey(final HystrixCommandKey fromConstructor, Class<?> clazz) {\n        if (fromConstructor == null || fromConstructor.name().trim().equals(\"\")) {\n            final String keyName = getDefaultNameFromClass(clazz);\n            return HystrixCommandKey.Factory.asKey(keyName);\n        } else {\n            return fromConstructor;\n        }\n    }\n\n    private static HystrixCommandProperties initCommandProperties(HystrixCommandKey commandKey, HystrixPropertiesStrategy propertiesStrategy, HystrixCommandProperties.Setter commandPropertiesDefaults) {\n        if (propertiesStrategy == null) {\n            return HystrixPropertiesFactory.getCommandProperties(commandKey, commandPropertiesDefaults);\n        } else {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-core/src/main/java/com/netflix/hystrix/AbstractCommand.java#L170-L206","documentation":"Hystrix requires every command to belong to a HystrixCommandGroupKey; the AbstractCommand constructor validates this in initGroupKey and throws IllegalStateException when the group key passed in is null. The group key is used primarily for reporting/alerting grouping (thread pools are keyed by commandKey or threadPoolKey).","triggerScenarios":"Constructing new HystrixCommand(null) or new HystrixObservableCommand(null), or calling HystrixCommand.Factory with a null group while also omitting a threadPoolKey path that would otherwise not need it; also subclass constructors that forward a null group field.","commonSituations":"Refactoring removes the group-key constant and passes null by mistake; copy-paste constructor calls where the group argument was deleted; migrating from HystrixCommand(group) to builder-style APIs and forgetting to set the group.","solutions":["Pass a non-null HystrixCommandGroupKey.Factory.asKey(\"GroupName\") to the command constructor","If a group genuinely does not apply, define a synthetic grouping key (e.g. the same string as the commandKey) rather than null","Add a unit test asserting every command subclass constructor forwards a non-null group key"],"exampleFix":"// before\nnew HystrixCommand<String>(null) { protected String run() { return \"x\"; } };\n// after\nnew HystrixCommand<String>(HystrixCommandGroupKey.Factory.asKey(\"OrderService\")) { protected String run() { return \"x\"; } };","handlingStrategy":"validation","validationCode":"HystrixCommandGroupKey group = HystrixCommandGroupKey.Factory.asKey(\"OrderService\");\nif (group == null || group.name() == null) throw new IllegalArgumentException(\"group key required\");","typeGuard":"// Java: null-check the key before constructing the command\nstatic boolean isValidGroupKey(HystrixCommandGroupKey k) { return k != null && k.name() != null && !k.name().trim().isEmpty(); }","tryCatchPattern":"Not productive to catch — validate inputs before constructing; an IllegalStateException here is a programming error surfaced at construction time.","preventionTips":["Never pass null as the group key; centralize key factories in one constants class","Add constructor-parameter tests for all command subclasses"],"tags":["java","hystrix","configuration","constructor-validation"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}