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

  1. Make the body's appId identical to the path appId before sending (set appModel.setAppId(appId)).
  2. If your client builds the body from a fetched App, re-fetch by the same appId used in the URL.
  3. Avoid relying on implicit defaults; always populate appId explicitly.
  4. 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

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


AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14). Data as JSON: /api/errors/8648903c4167d00d. Report an issue: GitHub.