flowable/flowable-engine · error · FlowableIllegalArgumentException
latest can only be used together with a deployment key
Error message
latest can only be used together with a deployment key
What it means
AppDeploymentQueryImpl.latest() throws FlowableIllegalArgumentException when no deployment key has been set on the query. 'latest' means 'pick the newest deployment for a given key', so it is only meaningful in combination with deploymentKey(...). Calling latest() on a key-less query would be ambiguous and is rejected.
Solutions
- Call deploymentKey(...) before latest() so the query has a key to resolve the latest deployment for
- If you want all deployments ordered by deployment time, sort by deploymentTime desc instead of using latest()
- Remove the latest() call if you did not intend key-scoped latest-version semantics
Example fix
// before
AppDeployment d = appDeploymentService.createDeploymentQuery().latest().singleResult();
// after
AppDeployment d = appDeploymentService.createDeploymentQuery()
.deploymentKey("myApp")
.latest()
.singleResult(); Defensive patterns
Strategy: validation
Validate before calling
if (useLatest) {
if (deploymentKey == null) {
throw new IllegalArgumentException("latest() requires deploymentKey to be set");
}
query.deploymentKey(deploymentKey).latest();
} Type guard
boolean canUseLatest = deploymentKey != null && useLatest;
Try / catch
try {
query.latest();
} catch (FlowableIllegalArgumentException e) {
throw new IllegalStateException("latest() used without deploymentKey — set the key first", e);
} Prevention
- Always pair latest() with deploymentKey(...) in a builder helper
- Document that latest() is key-scoped, not a global flag
- Write an integration test for the latest-version lookup path
When it happens
Trigger: Calling appDeploymentService.createDeploymentQuery().latest() without a preceding deploymentKey("someKey") call.
Common situations: Upgrading auto-deployment logic that wants the newest version of an app definition; copying query code from an example that set a key in a removed line; misunderstanding latest() as a global 'latest deployments' flag.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- Provided event definition must have a deployment id.
- A channel key detection value is required for inbound…
- A channel key detection value is required for the channel…
- A datasource is required for initializing the engine
- A delegated cannot be completed, but should be resolved…
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/94c687679f057685.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-app-engine/src/main/java/org/flowable/app/engine/impl/repository/AppDeploymentQueryImpl.java:147
@Override
public AppDeploymentQueryImpl deploymentTenantIdLike(String tenantIdLike) {
if (tenantIdLike == null) {
throw new FlowableIllegalArgumentException("deploymentTenantIdLike is null");
}
this.tenantIdLike = tenantIdLike;
return this;
}
@Override
public AppDeploymentQueryImpl deploymentWithoutTenantId() {
this.withoutTenantId = true;
return this;
}
@Override
public AppDeploymentQueryImpl latest() {
if (key == null) {
throw new FlowableIllegalArgumentException("latest can only be used together with a deployment key");
}
this.latest = true;
return this;
}
// sorting ////////////////////////////////////////////////////////
@Override
public AppDeploymentQuery orderByDeploymentId() {
return orderBy(AppDeploymentQueryProperty.DEPLOYMENT_ID);
}
@Override
public AppDeploymentQuery orderByDeploymentTime() {
return orderBy(AppDeploymentQueryProperty.DEPLOY_TIME);
}
View on GitHub (pinned to d6d39ce1c6)