{"record":{"id":"3943fc9506d872b9","repo":"flowable/flowable-engine","slug":"error-code-must-not-be-empty","errorCode":null,"errorMessage":"Error code must not be empty.","messagePattern":"Error code must not be empty\\.","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":58,"sourceCode":"        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    }\n\n    public abstract void addAdditionalData(String name, Object value);\n}","sourceCodeStart":40,"sourceCodeEnd":76,"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#L40-L76","documentation":"BusinessError.setErrorCode throws FlowableIllegalArgumentException(\"Error code must not be empty.\") when a BusinessError is constructed with an empty-string error code. The error code must be a non-null, non-empty string to be usable in error-boundary/bpmn error matching.","triggerScenarios":"Invoking a BusinessError constructor with \"\" as errorCode, or a subclass calling setErrorCode(\"\").","commonSituations":"Error codes read from configuration files or process variables that are present but empty, trimmed strings that end up as \"\", or template-generated code values that were left blank.","solutions":["Pass a meaningful non-empty error code string when constructing the BusinessError","Validate/trim and default the code before construction: if (code == null || code.isBlank()) code = \"DEFAULT\";","Check the source (config/variable) of the code for blank values and fix the upstream data"],"exampleFix":"// before\nString code = config.get(\"businessErrorCode\"); // may be \"\"\nthrow new BusinessError(code, null);\n// after\nString code = config.getOrDefault(\"businessErrorCode\", \"DEFAULT\").trim();\nif (code.isEmpty()) { code = \"DEFAULT\"; }\nthrow new BusinessError(code, null);","handlingStrategy":"validation","validationCode":"// guard before constructing a BusinessError\nString trimmed = errorCode == null ? null : errorCode.trim();\nif (trimmed == null || trimmed.isEmpty()) {\n    throw new IllegalArgumentException(\"Business error code must be non-empty\");\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":["Trim and validate codes sourced from configuration or process variables","Reject blank config values at startup rather than at throw time","Use a helper factory method that centralizes code validation","Test error-code plumbing with empty-string inputs"],"tags":["java","validation","bpmn","empty-string"],"backgroundTag":"empty-required-field","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"}