apolloconfig/apollo · warning · BadRequestException
The App Id of path variable and request body is different
Error message
The App Id of path variable and request body is different
What it means
BadRequestException (HTTP 400) from AppController.update (PUT /apps/{appId}). The handler guards that the appId in the path variable equals the appId in the submitted AppModel body; a mismatch means the client is trying to update a different app than the URL identifies, which is rejected before any service call.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java:143
return appService.findByAppIds(appIds, page);
}
@PreAuthorize(value = "@unifiedPermissionValidator.hasCreateApplicationPermission()")
@PostMapping
@ApolloAuditLog(type = OpType.CREATE, name = "App.create")
public App create(@Valid @RequestBody AppModel appModel) {
App app = transformToApp(appModel);
return appService.createAppAndAddRolePermission(app, appModel.getAdmins(),
userInfoHolder.getUser().getUserId());
}
@PreAuthorize(value = "@unifiedPermissionValidator.isAppAdmin(#appId)")
@PutMapping("/{appId:.+}")
@ApolloAuditLog(type = OpType.UPDATE, name = "App.update")
public void update(@PathVariable String appId, @Valid @RequestBody AppModel appModel) {
if (!Objects.equals(appId, appModel.getAppId())) {
throw new BadRequestException("The App Id of path variable and request body is different");
}
App app = transformToApp(appModel);
App updatedApp = appService.updateAppInLocal(app, userInfoHolder.getUser().getUserId());
publisher.publishEvent(new AppInfoChangedEvent(updatedApp));
}
@GetMapping("/{appId}/navtree")
public MultiResponseEntity<EnvClusterInfo> nav(@PathVariable String appId) {
MultiResponseEntity<EnvClusterInfo> response = MultiResponseEntity.ok();
List<Env> envs = portalSettings.getActiveEnvs();
for (Env env : envs) {
try {
response.addResponseEntity(RichResponseEntity.ok(appService.createEnvNavNode(env, appId)));
} catch (Exception e) {View on GitHub (pinned to d95fc18d11)
Solutions
- Make the body's appId identical to the path appId before sending (set appModel.setAppId(appId)).
- If your client builds the body from a fetched App, re-fetch by the same appId used in the URL.
- Avoid relying on implicit defaults; always populate appId explicitly.
- Add a client-side equality assertion before the PUT (see validationCode).
Example fix
// before
PUT /apps/sample-app body: { "appId": "sampleApp", ... } // mismatch
// after
PUT /apps/sample-app body: { "appId": "sample-app", ... } Defensive patterns
Strategy: validation
Validate before calling
// Assert path appId == body appId before PUT /apps/{appId}.
String appId = pathAppId; // from URL
if (!Objects.equals(appId, appModel.getAppId())) {
appModel.setAppId(appId); // fix implicitly, or abort
}
assert Objects.equals(appId, appModel.getAppId()); Type guard
static boolean appModelMatchesPath(AppModel body, String pathAppId) {
return body != null && Objects.equals(pathAppId, body.getAppId());
} Prevention
- Always set body.appId from the same variable used to build the URL.
- Re-fetch the App by the path appId before editing.
- Unit-test the equality assertion in your client.
- Avoid caching AppModel objects across different apps.
When it happens
Trigger: PUT /apps/{appId} (e.g. /apps/sample-app) with a request body whose appId field (appModel.getAppId()) differs from the {appId} path segment.
Common situations: Frontend bug sending a stale/cached AppModel; copy-paste of a curl body from another app without updating both the URL and body; id-normalization (trim/case) making the two strings unequal.
Related errors
- The App Id of path variable and request body is different
- AppId not equal. AppId in path = %s, AppId in payload = %s
- Comment item's key or value should be blank.
- Comment item's comment should not be blank.
- value too long. length limit:%s
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/8648903c4167d00d.
Report an issue: GitHub.