{"record":{"id":"06c1d490b08da038","repo":"flowable/flowable-engine","slug":"error-code-must-not-be-null","errorCode":null,"errorMessage":"Error code must not be null.","messagePattern":"Error code must not be null\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common-api/src/main/java/org/flowable/common/engine/api/delegate/BusinessError.java","lineNumber":55,"sourceCode":"\n    protected BusinessError(String errorCode) {\n        super(\"\");\n        setErrorCode(errorCode);\n    }\n\n    protected BusinessError(String errorCode, String message) {\n        super(message);\n        setErrorCode(errorCode);\n    }\n\n    protected BusinessError(String errorCode, String message, Throwable cause) {\n        super(message, cause);\n        setErrorCode(errorCode);\n    }\n\n    protected void setErrorCode(String errorCode) {\n        if (errorCode == null) {\n            throw new FlowableIllegalArgumentException(\"Error code must not be null.\");\n        }\n        if (errorCode.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Error code must not be empty.\");\n        }\n        this.errorCode = errorCode;\n    }\n\n    public String getErrorCode() {\n        return errorCode;\n    }\n\n    public VariableContainer getAdditionalDataContainer() {\n        return additionalDataContainer;\n    }\n\n    public void setAdditionalDataContainer(VariableContainer additionalDataContainer) {\n        this.additionalDataContainer = additionalDataContainer;\n    }","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common-api/src/main/java/org/flowable/common/engine/api/delegate/BusinessError.java#L37-L73","documentation":"BusinessError.setErrorCode throws FlowableIllegalArgumentException(\"Error code must not be null.\") when a BusinessError (or subclass) is constructed with a null error code. Business errors are used e.g. in business-rule task / BpmnError semantics where a non-null error code is required by contract.","triggerScenarios":"Invoking a BusinessError constructor with null as errorCode, or calling setErrorCode(null) via the protected setter from a subclass.","commonSituations":"Dynamically computing an error code from a variable or process value that is null, custom BusinessError subclasses not initializing the code, or refactoring where the code constant was removed.","solutions":["Pass a non-null, non-empty string as the errorCode when constructing the BusinessError","If the code is computed, default it (e.g. code != null ? code : \"DEFAULT_ERROR\") before constructing","Audit custom BusinessError subclasses to ensure constructors always call super with a valid code"],"exampleFix":"// before\nString code = (String) execution.getVariable(\"errorCode\");\nthrow new BusinessError(code, null);\n// after\nString code = Objects.toString(execution.getVariable(\"errorCode\"), \"DEFAULT_BUSINESS_ERROR\");\nthrow new BusinessError(code, null);","handlingStrategy":"validation","validationCode":"// guard before constructing a BusinessError\nif (errorCode == null) {\n    throw new IllegalArgumentException(\"Business error code must be provided\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    throw new BusinessError(code, cause);\n} catch (FlowableIllegalArgumentException e) {\n    LOGGER.error(\"Invalid business error code: {}\", e.getMessage());\n    throw new BusinessError(\"DEFAULT_BUSINESS_ERROR\", cause);\n}","preventionTips":["Never pass raw process variables as error codes without null-checking","Default computed codes before construction","Audit custom BusinessError subclasses for constructor paths that skip the code","Keep error codes as named constants instead of dynamic values where possible"],"tags":["java","validation","bpmn","null"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}