alibaba/nacos · warning · NacosException

INVALID_PARAM

INVALID_PARAM

Error message

Configuration cannot be null

What it means

Thrown by ConsoleCopilotConfigController.saveConfig (POST /v3/console/.../copilot/config, @Since 3.2.0) when the request carries no JSON body, so the @RequestBody CopilotProperties parameter binds to null. It uses NacosException.INVALID_PARAM (HTTP 400). The controller intentionally requires a body because it merges the submitted apiKey/model/studioUrl/studioProject onto the stored CopilotProperties.

Source

Thrown at console/src/main/java/com/alibaba/nacos/console/controller/v3/ai/ConsoleCopilotConfigController.java:127

    }
    
    /**
     * Create or update Copilot configuration. Only accepts apiKey, model, studioUrl and studioProject fields, other
     * fields use defaults.
     *
     * @param request HTTP servlet request.
     * @param config Simplified CopilotProperties with only apiKey, model, studioUrl and studioProject
     * @return success result
     */
    @Since("3.2.0")
    @PostMapping
    @Secured(resource = CONSOLE_RESOURCE_NAME_PREFIX + "copilot/config",
        action = ActionTypes.WRITE, signType = SignType.AI, apiType = ApiType.CONSOLE_API)
    public Result<Boolean> saveConfig(HttpServletRequest request,
        @RequestBody CopilotProperties config)
        throws NacosException {
        if (config == null) {
            throw new NacosException(NacosException.INVALID_PARAM, "Configuration cannot be null");
        }
        
        // Get existing config to preserve other fields, or create new one with defaults
        CopilotProperties existingConfig = getStoredConfig();
        CopilotProperties fullConfig;
        
        if (existingConfig != null) {
            // Use existing config and only update apiKey, model, studioUrl and studioProject
            fullConfig = existingConfig;
        } else {
            // Create new config with default values
            fullConfig = new CopilotProperties();
        }
        
        // Update only apiKey, model, studioUrl and studioProject
        if (config.getApiKey() != null) {
            fullConfig.setApiKey(config.getApiKey());
        }

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Send a JSON object in the request body with Content-Type: application/json; an empty object '{}' is accepted.
  2. If using a typed client, make sure the CopilotProperties payload object is constructed and serialized rather than passed as null.
  3. Verify no intermediary (gateway/RestTemplate) is dropping the body or the Content-Type header before it reaches the controller.
  4. Check the HTTP request on the client side to confirm the body is actually transmitted before calling the API.

Example fix

// before
POST /v3/console/ai/copilot/config
Content-Type: application/json

// after
POST /v3/console/ai/copilot/config
Content-Type: application/json

{}
Defensive patterns

Strategy: validation

Validate before calling

// Ensure a non-null body is sent before calling saveConfig
CopilotProperties body = new CopilotProperties();
if (body == null) {
    throw new IllegalArgumentException("Copilot config body must not be null");
}
restTemplate.postForObject(copilotConfigUrl, body, Result.class);

Type guard

// Java: guard that a serializable body exists before the call
boolean hasConfigBody = body != null;
if (!hasConfigBody) { /* do not call the API */ }

Try / catch

try {
    saveConfig(request, body);
} catch (NacosException e) {
    if (e.getErrCode() == NacosException.INVALID_PARAM) {
        // body was null/missing; fix the request payload
    } else { throw e; }
}

Prevention

When it happens

Trigger: POSTing to the copilot config endpoint with an empty body, a wrong Content-Type (not application/json), or a literal JSON null. The @RequestBody parameter resolves to null and the guard at line 127 fires.

Common situations: Console UI or automation sending a save-config request without serializing the form; curl without -d; a proxy stripping the body or Content-Type header; an integration test that posts an empty entity.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/eb35aa4e7c3b564b. Report an issue: GitHub.