{"record":{"id":"7e18b790a6f932ea","repo":"alibaba/spring-ai-alibaba","slug":"missing-params-7e18b7","errorCode":"MISSING_PARAMS","errorMessage":"Required parameters [apiKey] missing, please check the request parameters.","messagePattern":"Required parameters \\[apiKey\\] missing, please check the request parameters\\.","errorType":"error_code","errorClass":"BizException","httpStatus":400,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/controller/ApiKeyController.java","lineNumber":61,"sourceCode":"\n\t/** Service for handling API key operations */\n\tprivate final ApiKeyService apiKeyService;\n\n\tpublic ApiKeyController(ApiKeyService apiKeyService) {\n\t\tthis.apiKeyService = apiKeyService;\n\t}\n\n\t/**\n\t * Creates a new API key\n\t * @param apiKey API key information\n\t * @return Result containing the created API key ID\n\t */\n\t@PostMapping()\n\tpublic Result<String> createApiKey(@RequestBody ApiKey apiKey) {\n\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\n\t\tif (Objects.isNull(apiKey)) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"apiKey\"));\n\t\t}\n\n\t\tif (StringUtils.isBlank(apiKey.getDescription())) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"description\"));\n\t\t}\n\n\t\tLong id = apiKeyService.createApiKey(apiKey);\n\t\treturn Result.success(context.getRequestId(), String.valueOf(id));\n\t}\n\n\t/**\n\t * Updates an existing API key\n\t * @param id API key ID\n\t * @param apiKey Updated API key information\n\t * @return Result indicating success\n\t */\n\t@PutMapping(\"/{id}\")\n\tpublic Result<String> updateApiKey(@PathVariable(\"id\") Long id, @RequestBody ApiKey apiKey) {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/controller/ApiKeyController.java#L43-L79","documentation":"MISSING_PARAMS BizException from ApiKeyController.createApiKey, thrown when the @RequestBody ApiKey object is null. A required @RequestBody is normally enforced by Spring (400 if body absent), so a null here indicates the body resolved to null under non-standard invocation or configuration. The create endpoint needs an ApiKey payload containing at least a description.","triggerScenarios":"POST /api-keys with no/empty body under permissive config, or direct invocation createApiKey(null).","commonSituations":"Missing Content-Type: application/json header; empty request body; tests calling the handler directly with null.","solutions":["Send a JSON body: {\"description\": \"...\"} with Content-Type: application/json.","Ensure the body is non-empty.","Call createApiKey(new ApiKey()) in tests rather than null.","Verify Spring's required-body enforcement is not disabled."],"exampleFix":"// before\npost(\"/api-keys\", null);\n// after\npost(\"/api-keys\", \"{\\\"description\\\": \\\"prod key\\\"}\");","handlingStrategy":"validation","validationCode":"if (apiKey == null || apiKey.getDescription() == null || apiKey.getDescription().isBlank()) { throw new IllegalArgumentException(\"apiKey body with description is required\"); }","typeGuard":"boolean hasApiKeyBody(ApiKey k) { return k != null; }","tryCatchPattern":"try {\n    String id = apiKeyApi.createApiKey(key);\n} catch (BizException e) {\n    if (\"MISSING_PARAMS\".equals(e.getCode())) {\n        throw new IllegalArgumentException(\"API key payload is required\", e);\n    }\n}","preventionTips":["Always send a JSON ApiKey body on POST /api-keys.","Set Content-Type: application/json.","Never send an empty body to @RequestBody endpoints.","Construct the payload object explicitly in tests."],"tags":["rest","missing-params","api-key"],"backgroundTag":"missing-required-argument","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}