{"record":{"id":"de4818a1f634fbbd","repo":"flowable/flowable-engine","slug":"must-specify-a-process-definition-key-to-migrate-de4818","errorCode":null,"errorMessage":"Must specify a process definition key to migrate","messagePattern":"Must specify a process definition key to migrate","errorType":"validation","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ProcessInstanceMigrationValidationCmd.java","lineNumber":61,"sourceCode":"        this.processInstanceMigrationDocument = processInstanceMigrationDocument;\n    }\n\n    public ProcessInstanceMigrationValidationCmd(ProcessInstanceMigrationDocument processInstanceMigrationDocument, String processDefinitionId) {\n        if (processDefinitionId == null) {\n            throw new FlowableException(\"Must specify a process definition id to migrate\");\n        }\n        \n        if (processInstanceMigrationDocument == null) {\n            throw new FlowableException(\"Must specify a process migration document to migrate\");\n        }\n\n        this.processDefinitionId = processDefinitionId;\n        this.processInstanceMigrationDocument = processInstanceMigrationDocument;\n    }\n\n    public ProcessInstanceMigrationValidationCmd(String processDefinitionKey, int processDefinitionVersion, String processDefinitionTenantId, ProcessInstanceMigrationDocument processInstanceMigrationDocument) {\n        if (processDefinitionKey == null) {\n            throw new FlowableException(\"Must specify a process definition key to migrate\");\n        }\n        \n        if (processInstanceMigrationDocument == null) {\n            throw new FlowableException(\"Must specify a process migration document to migrate\");\n        }\n\n        this.processDefinitionKey = processDefinitionKey;\n        this.processDefinitionVersion = processDefinitionVersion;\n        this.processInstanceMigrationDocument = processInstanceMigrationDocument;\n        this.processDefinitionTenantId = processDefinitionTenantId;\n    }\n\n    @Override\n    public ProcessInstanceMigrationValidationResult execute(CommandContext commandContext) {\n\n        ProcessInstanceMigrationManager migrationManager = CommandContextUtil.getProcessEngineConfiguration(commandContext).getProcessInstanceMigrationManager();\n\n        if (processInstanceId != null) {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/ProcessInstanceMigrationValidationCmd.java#L43-L79","documentation":"The key/version/tenant constructor of ProcessInstanceMigrationValidationCmd validates all instances of a definition identified by key and version. It throws when the processDefinitionKey argument is null, because a null key cannot identify any process definition. This is a constructor-level precondition check.","triggerScenarios":"Calling new ProcessInstanceMigrationValidationCmd(null, version, tenantId, document) directly, or passing a null key variable obtained from configuration or a lookup that missed.","commonSituations":"Externalized config (properties/YAML) missing the definition key so the injected value is null; renaming a process definition in the model without updating caller configuration; direct use of internal command classes.","solutions":["Supply the actual process definition key from the BPMN model (the id attribute of <process>), not the definition id or name","Null-check configuration before calling; fail early with a clear message if the key is missing","Prefer the public API migrateToProcessDefinition(key, version, tenantId) on the migration builder, which routes through this constructor correctly"],"exampleFix":"// before\nString key = config.get(\"migration.key\"); // null when unset\nnew ProcessInstanceMigrationValidationCmd(key, 2, tenantId, doc);\n// after\nString key = config.get(\"migration.key\");\nif (key != null && !key.isEmpty()) {\n    new ProcessInstanceMigrationValidationCmd(key, 2, tenantId, doc);\n}","handlingStrategy":"validation","validationCode":"if (processDefinitionKey == null || processDefinitionKey.isEmpty()) {\n    throw new IllegalArgumentException(\"processDefinitionKey must match the <process> id in the BPMN model\");\n}","typeGuard":"boolean hasDefinitionKey(String key) { return key != null && !key.isEmpty(); }","tryCatchPattern":"try {\n    validationCmd.execute(commandContext);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"Must specify a process definition key\")) {\n        // load key from config/BPMN model and retry\n    }\n    throw e;\n}","preventionTips":["Externalize the definition key in config and validate at startup","Use the id attribute of <process> in the BPMN XML, not the deployment name","Verify keys after model refactors/renames"],"tags":["flowable","process-migration","null-argument","configuration"],"backgroundTag":"missing-required-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}