{"record":{"id":"f39f85b73cf8c57a","repo":"flowable/flowable-engine","slug":"error-code-must-not-be-empty-f39f85","errorCode":null,"errorMessage":"Error Code must not be empty.","messagePattern":"Error Code must not be empty\\.","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/delegate/BpmnError.java","lineNumber":52,"sourceCode":"\n    private String errorCode;\n\n    public BpmnError(String errorCode) {\n        super(\"\");\n        setErrorCode(errorCode);\n    }\n\n    public BpmnError(String errorCode, String message) {\n        super(message + \" (errorCode='\" + errorCode + \"')\");\n        setErrorCode(errorCode);\n    }\n\n    protected void setErrorCode(String errorCode) {\n        if (errorCode == null) {\n            throw new ActivitiIllegalArgumentException(\"Error Code must not be null.\");\n        }\n        if (errorCode.length() < 1) {\n            throw new ActivitiIllegalArgumentException(\"Error Code must not be empty.\");\n        }\n        this.errorCode = errorCode;\n    }\n\n    public String getErrorCode() {\n        return errorCode;\n    }\n\n    @Override\n    public String toString() {\n        return super.toString() + \" (errorCode='\" + errorCode + \"')\";\n    }\n\n}\n","sourceCodeStart":34,"sourceCodeEnd":67,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/delegate/BpmnError.java#L34-L67","documentation":"Besides being non-null, a BpmnError errorCode must have length >= 1. setErrorCode() throws ActivitiIllegalArgumentException(\"Error Code must not be empty.\") when an empty string is supplied, because an empty code can never be matched by any error boundary event definition.","triggerScenarios":"new BpmnError(\"\") or new BpmnError(message, \"\") — constructors receiving an empty-string error code.","commonSituations":"Error code read from a config file / process variable / DB column that is empty string rather than null; string building that produced \"\" (e.g. split or substring yielding empty).","solutions":["Provide a real non-empty error code matching the errorCode attribute of the boundary/error start event in the BPMN XML.","Trim and check before throwing: if (code == null || code.trim().isEmpty()) code = fallback.","Fix the upstream data source producing the empty string."],"exampleFix":"// before\nthrow new BpmnError(errorCode); // errorCode == \"\"\n// after\nif (errorCode == null || errorCode.trim().isEmpty()) {\n    errorCode = \"UNSPECIFIED_ERROR\";\n}\nthrow new BpmnError(errorCode);","handlingStrategy":"validation","validationCode":"if (errorCode == null || errorCode.trim().isEmpty()) errorCode = \"UNSPECIFIED_ERROR\";","typeGuard":"boolean isNonEmpty(String s) { return s != null && !s.trim().isEmpty(); }","tryCatchPattern":"try { serviceCall(); } catch (ActivitiIllegalArgumentException e) { if (e.getMessage().contains(\"must not be empty\")) { throw new BpmnError(\"FALLBACK_CODE\"); } throw e; }","preventionTips":["Trim/normalize error codes read from external sources before use","Define error codes as constants in one enum/class","Add unit tests asserting every thrown BpmnError has a non-empty code"],"tags":["bpmn","empty-string","validation","error-handling"],"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"}