{"record":{"id":"b06756d288d7f156","repo":"Netflix/Hystrix","slug":"command-should-implement-interface-to-execute-i-b06756","errorCode":null,"errorMessage":"Command should implement {} interface to execute in observable mode","messagePattern":"Command should implement (.+?) interface to execute in observable mode","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/CommandExecutor.java","lineNumber":82,"sourceCode":"                return ObservableExecutionMode.EAGER == metaHolder.getObservableExecutionMode() ? observable.observe() : observable.toObservable();\n            }\n            default:\n                throw new RuntimeException(\"unsupported execution type: \" + executionType);\n        }\n    }\n\n    private static HystrixExecutable castToExecutable(HystrixInvokable invokable, ExecutionType executionType) {\n        if (invokable instanceof HystrixExecutable) {\n            return (HystrixExecutable) invokable;\n        }\n        throw new RuntimeException(\"Command should implement \" + HystrixExecutable.class.getCanonicalName() + \" interface to execute in: \" + executionType + \" mode\");\n    }\n\n    private static HystrixObservable castToObservable(HystrixInvokable invokable) {\n        if (invokable instanceof HystrixObservable) {\n            return (HystrixObservable) invokable;\n        }\n        throw new RuntimeException(\"Command should implement \" + HystrixObservable.class.getCanonicalName() + \" interface to execute in observable mode\");\n    }\n\n}\n","sourceCodeStart":64,"sourceCodeEnd":86,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-contrib/hystrix-javanica/src/main/java/com/netflix/hystrix/contrib/javanica/command/CommandExecutor.java#L64-L86","documentation":"For ExecutionType.OBSERVABLE the invokable must implement HystrixObservable (i.e. be a HystrixObservableCommand). Javanica throws this RuntimeException when the factory produced a plain HystrixCommand-based invokable (GenericCommand, which implements HystrixExecutable but not HystrixObservable) while the dispatch path tries observe()/toObservable() — again an invokable-kind vs execution-type mismatch.","triggerScenarios":"Method/return-type metadata resolved to OBSERVABLE execution while the constructed invokable is a plain GenericCommand — e.g. custom factory overrides, collapser batch meta-holder built from a non-observable command but executed in observable mode, or skewed javanica versions.","commonSituations":"Extending HystrixCommandFactory without handling all execution types; mixing javanica jar versions so factory selection and execution-type derivation disagree; edge-case collapser signatures.","solutions":["Align hystrix-javanica and hystrix-core versions and remove duplicate javanica jars (mvn dependency:tree | grep hystrix).","If you customize the command factory, return HystrixObservableCommand-based invokables (e.g. GenericObservableCommand) whenever metaHolder execution type is OBSERVABLE.","Reproduce with a minimal method returning Observable<T> to confirm stock javanica works, then bisect your customizations."],"exampleFix":"// custom factory sketch\n// before\nif (metaHolder.isObservable()) {\n    return new GenericCommand(metaHolder);   // wrong kind for OBSERVABLE\n}\n// after\nif (metaHolder.isObservable()) {\n    return new GenericObservableCommand(metaHolder);  // implements HystrixObservable\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { ... } catch (RuntimeException e) when message contains 'Command should implement' → log observable-mode mismatch (invokable class + executionType) and rethrow; not retryable.","preventionTips":["Align hystrix-core and hystrix-javanica versions; eliminate duplicate javanica jars.","If overriding HystrixCommandFactory, add a unit test per ExecutionType asserting the invokable implements HystrixExecutable/HystrixObservable accordingly."],"tags":["hystrix","javanica","execution-type","observable","internal"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}