halo-dev/halo · warning · ServerWebInputException

The name from the request body does not match the plugin con

Error message

The name from the request body does not match the plugin configMapName name.

What it means

Inside updatePluginConfig, after the configMapName precondition passes, the handler reads the request body as a ConfigMap and compares configMapToUpdate.getMetadata().getName() against the plugin's configMapName. It throws ServerWebInputException (HTTP 400) if they differ, to prevent a client from writing a different ConfigMap's data through this plugin-scoped endpoint.

Source

Thrown at application/src/main/java/run/halo/app/core/endpoint/console/PluginEndpoint.java:486

    private Mono<ServerResponse> updatePluginConfig(ServerRequest request) {
        final var pluginName = request.pathVariable("name");
        return client.fetch(Plugin.class, pluginName)
                .doOnNext(plugin -> {
                    String configMapName = plugin.getSpec().getConfigMapName();
                    if (!StringUtils.hasText(configMapName)) {
                        throw new ServerWebInputException(
                                "Unable to complete the request because the plugin configMapName is blank");
                    }
                })
                .flatMap(plugin -> {
                    final String configMapName = plugin.getSpec().getConfigMapName();
                    return request.bodyToMono(ConfigMap.class)
                            .doOnNext(configMapToUpdate -> {
                                var configMapNameToUpdate =
                                        configMapToUpdate.getMetadata().getName();
                                if (!configMapName.equals(configMapNameToUpdate)) {
                                    throw new ServerWebInputException(
                                            "The name from the request body does not match the plugin "
                                                    + "configMapName name.");
                                }
                            })
                            .flatMap(configMapToUpdate -> client.fetch(ConfigMap.class, configMapName)
                                    .map(persisted -> {
                                        configMapToUpdate
                                                .getMetadata()
                                                .setVersion(
                                                        persisted.getMetadata().getVersion());
                                        return configMapToUpdate;
                                    })
                                    .switchIfEmpty(client.create(configMapToUpdate)))
                            .flatMap(client::update)
                            .retryWhen(Retry.backoff(5, Duration.ofMillis(300))
                                    .filter(OptimisticLockingFailureException.class::isInstance));
                })
                .flatMap(configMap -> ServerResponse.ok().bodyValue(configMap));

View on GitHub (pinned to d2f5165f9c)

Solutions

  1. Set the body's metadata.name to the plugin's actual configMapName before submitting.
  2. Fetch the existing ConfigMap and edit in place rather than constructing a new body.
  3. On the client, derive metadata.name from the plugin's spec.configMapName, never hard-code it.

Example fix

// before
PUT /plugins/foo/config { "metadata": { "name": "wrong-name" }, ... } // 400

// after
PUT /plugins/foo/config { "metadata": { "name": "<plugin.spec.configMapName>" }, ... }
Defensive patterns

Strategy: validation

Validate before calling

String expected = plugin.getSpec().getConfigMapName();
if (!expected.equals(configMapBody.getMetadata().getName())) {
    return Mono.error(new ServerWebInputException(
        "The name from the request body does not match the plugin configMapName name."));
}

Type guard

static boolean nameMatches(Plugin p, ConfigMap body) {
    return p != null && body != null
        && java.util.Objects.equals(p.getSpec().getConfigMapName(),
                                    body.getMetadata().getName());
}

Prevention

When it happens

Trigger: Sending a ConfigMap body whose metadata.name is not equal to the target plugin's configMapName — e.g. copying a config body from another plugin, or sending a default/empty metadata.name.

Common situations: Client reuses a config payload from plugin A when saving plugin B; frontend bug sending a stale or template metadata.name; manually constructed request with the wrong ConfigMap name.

Related errors


AI-assisted analysis of halo-dev/halo@d2f5165f9c (2026-08-14). Data as JSON: /api/errors/6542a6c5c718dcde. Report an issue: GitHub.