{"record":{"id":"6db4186c8a94de3f","repo":"flowable/flowable-engine","slug":"provided-decision-definition-must-have-both-key-an","errorCode":null,"errorMessage":"Provided decision definition must have both key and resource name set.","messagePattern":"Provided decision definition must have both key and resource name set\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/deployer/DecisionRequirementsDiagramHelper.java","lineNumber":42,"sourceCode":"import org.slf4j.LoggerFactory;\n\n/**\n * Creates diagrams from decision definitions.\n */\npublic class DecisionRequirementsDiagramHelper {\n\n    private static final Logger LOGGER = LoggerFactory.getLogger(DecisionRequirementsDiagramHelper.class);\n\n    /**\n     * Generates a diagram resource for a DecisionEntity. The returned resource has not yet been persisted, nor attached to the CaseDefinitionEntity. This requires\n     * that the DecisionEntity have its key and resource name already set.\n     * <p>\n     * The caller must determine whether creating a diagram for this decision is appropriate or not, for example see {@link #shouldCreateDiagram}.\n     */\n    public DmnResourceEntity createDiagramForDecision(DecisionEntity decision, DmnDefinition dmnDefinition) {\n\n        if (StringUtils.isEmpty(decision.getKey()) || StringUtils.isEmpty(decision.getResourceName())) {\n            throw new IllegalStateException(\"Provided decision definition must have both key and resource name set.\");\n        }\n\n        DmnResourceEntity resource = createResourceEntity();\n        DmnEngineConfiguration dmnEngineConfiguration = CommandContextUtil.getDmnEngineConfiguration();\n        try {\n            byte[] diagramBytes = IoUtil.readInputStream(\n                    dmnEngineConfiguration.getDecisionRequirementsDiagramGenerator().generateDiagram(dmnDefinition, \"png\",\n                            dmnEngineConfiguration.getDecisionFontName(),\n                            dmnEngineConfiguration.getLabelFontName(),\n                            dmnEngineConfiguration.getAnnotationFontName(),\n                            dmnEngineConfiguration.getClassLoader()), null);\n            String diagramResourceName = ResourceNameUtil.getDecisionRequirementsDiagramResourceName(\n                    decision.getResourceName(), decision.getKey(), \"png\");\n\n            resource.setName(diagramResourceName);\n            resource.setBytes(diagramBytes);\n            resource.setDeploymentId(decision.getDeploymentId());\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/deployer/DecisionRequirementsDiagramHelper.java#L24-L60","documentation":"DecisionRequirementsDiagramHelper.createDiagramForDecision requires the DecisionEntity to carry both a key and a resource name before it can generate a diagram resource; otherwise it throws IllegalStateException. This is an internal precondition: the caller (per shouldCreateDiagram) must ensure a valid decision definition.","triggerScenarios":"Deploying DMN where a parsed DecisionEntity ends up with an empty key or resourceName — typically a malformed DMN XML whose decision element lacks an id, or custom deployer/parsing code that builds decisions without setting those fields.","commonSituations":"Hand-edited or generated .dmn XML with missing decision id attribute; custom DmnParseHandlers that skip setting resourceName; version upgrades where decision entity population changed.","solutions":["Fix the DMN XML so each <decision id=\"...\"> has a non-empty id and is referenced from a valid resource.","In custom parsing/deployer code, set both key and resourceName on the DecisionEntity before diagram generation.","Validate DMN files with the XSD before deploying.","Check shouldCreateDiagram is honored so diagram creation only runs for complete decisions."],"exampleFix":"// before (custom parse handler)\nDecisionEntity decision = new DecisionEntityImpl();\n// key/resourceName never set\n// after\nDecisionEntity decision = new DecisionEntityImpl();\ndecision.setKey(decisionElement.getAttribute(\"id\"));\ndecision.setResourceName(resource.getName());","handlingStrategy":"validation","validationCode":"if (StringUtils.isEmpty(decision.getKey()) || StringUtils.isEmpty(decision.getResourceName())) {\n    throw new IllegalStateException(\"Decision must have key and resourceName before diagram generation\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return helper.createDiagramForDecision(decision, dmnDefinition);\n} catch (IllegalStateException e) {\n    log.warn(\"Skipping diagram for incomplete decision {}: {}\", decision.getKey(), e.getMessage());\n    return null;\n}","preventionTips":["Validate DMN XML ids before deploying","Set key and resourceName in any custom parse handler","Respect shouldCreateDiagram gating in custom deployers"],"tags":["flowable","dmn","invariant","diagram","deploy"],"backgroundTag":"internal-invariant-violation","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"}