apolloconfig/apollo · error · 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
A BadRequestException (HTTP 400) thrown from AppController.update() (PUT /apps/{appId}) when the appId in the URL path variable does not match the appId in the JSON request body (App.getAppId()). Apollo validates that the resource identifier in the path and the entity body agree before persisting. This is a standard REST idempotency guard against accidental cross-resource updates.
Source
Thrown at apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppController.java:115
accessKey.setMode(AccessKeyMode.FILTER);
accessKey.setEnabled(true);
accessKey.setDataChangeCreatedBy(operator);
return accessKey;
}
@DeleteMapping("/apps/{appId:.+}")
public void delete(@PathVariable("appId") String appId, @RequestParam String operator) {
App entity = appService.findOne(appId);
if (entity == null) {
throw NotFoundException.appNotFound(appId);
}
adminService.deleteApp(entity, operator);
}
@PutMapping("/apps/{appId:.+}")
public void update(@PathVariable String appId, @RequestBody App app) {
if (!Objects.equals(appId, app.getAppId())) {
throw new BadRequestException("The App Id of path variable and request body is different");
}
appService.update(app);
}
@GetMapping("/apps")
public List<AppDTO> find(@RequestParam(value = "name", required = false) String name,
Pageable pageable) {
List<App> app;
if (StringUtils.isBlank(name)) {
app = appService.findAll(pageable);
} else {
app = appService.findByName(name);
}
return BeanUtils.batchTransform(AppDTO.class, app);
}
@GetMapping("/apps/{appId:.+}")View on GitHub (pinned to d95fc18d11)
Solutions
- Ensure the appId in the URL path and the appId field in the request body are identical before sending.
- Derive the URL path variable from the same dto.getAppId() value used in the body.
- Validate client-side that the two match before issuing the PUT.
Example fix
// before: URL and body may diverge
String urlAppId = "myApp-001";
App app = new App();
app.setAppId("myApp-002"); // mismatch!
restTemplate.put("/apps/" + urlAppId, app);
// after: derive path from the same object
restTemplate.put("/apps/" + app.getAppId(), app); Defensive patterns
Strategy: validation
Validate before calling
// Validate path and body appId match before sending
if (!Objects.equals(pathAppId, app.getAppId())) {
throw new IllegalArgumentException("Path appId and body appId must match");
}
appService.update(pathAppId, app); // or derive path from app.getAppId() Prevention
- Always derive the URL path variable from the same dto.getAppId() used in the request body.
- Add a client-side assertion that path and body identifiers match before issuing PUT requests.
- Avoid constructing the URL and body from independent configuration sources.
When it happens
Trigger: PUT request to /apps/{appId:.+} where the JSON body's appId field differs from the {appId} segment in the URL. For example, PUT /apps/myApp-001 with body {"appId":"myApp-002", ...}.
Common situations: Client builds the URL from one source and the body from another (e.g., different config files); a copy-paste error when updating app metadata; a frontend bug that uses a stale appId in the URL after the user switched apps.
Related errors
- The App Id of path variable and request body is different
- Comment item's key or value should be blank.
- Comment item's comment should not be blank.
- AppId not equal. AppId in path = %s, AppId in payload = %s
- namespace:%s is modified by %s
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/ee54ea8bc8ae1c14.
Report an issue: GitHub.