{"record":{"id":"2ee426708536038a","repo":"alibaba/spring-ai-alibaba","slug":"missing-params-2ee426","errorCode":"MISSING_PARAMS","errorMessage":"knowledge_base","messagePattern":"knowledge_base","errorType":"error_code","errorClass":"BizException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/controller/KnowledgeBaseController.java","lineNumber":76,"sourceCode":"\tprivate final DocumentRetrieverManager documentRetrieverManager;\n\n\tpublic KnowledgeBaseController(KnowledgeBaseService knowledgeBaseService,\n\t\t\tDocumentRetrieverManager documentRetrieverManager) {\n\t\tthis.knowledgeBaseService = knowledgeBaseService;\n\t\tthis.documentRetrieverManager = documentRetrieverManager;\n\t}\n\n\t/**\n\t * Creates a new knowledge base\n\t * @param kb Knowledge base configuration\n\t * @return Result containing the created knowledge base ID\n\t */\n\t@PostMapping()\n\tpublic Result<String> createKnowledgeBase(@RequestBody KnowledgeBase kb) {\n\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\n\t\tif (Objects.isNull(kb)) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"knowledge_base\"));\n\t\t}\n\n\t\tif (StringUtils.isBlank(kb.getName())) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"name\"));\n\t\t}\n\n\t\tif (kb.getProcessConfig() == null) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"process_config\"));\n\t\t}\n\n\t\tif (kb.getIndexConfig() == null) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"index_config\"));\n\t\t}\n\n\t\tIndexConfig indexConfig = kb.getIndexConfig();\n\t\tif (StringUtils.isBlank(indexConfig.getEmbeddingProvider())) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"embedding_provider\"));\n\t\t}","sourceCodeStart":58,"sourceCodeEnd":94,"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/KnowledgeBaseController.java#L58-L94","documentation":"POSTing to the knowledge base collection requires a KnowledgeBase JSON body; when the body deserializes to null the controller throws BizException with ErrorCode.MISSING_PARAMS for \"knowledge_base\" before any service call is made.","triggerScenarios":"POST /knowledge-base (root path) with an empty body, or a body Spring cannot map to KnowledgeBase resulting in a null @RequestBody argument.","commonSituations":"Client sends no Content-Type: application/json header so the body is not read; empty POST from a script; sending form data instead of JSON.","solutions":["Send a JSON body representing a KnowledgeBase object with Content-Type: application/json","Include at least name, processConfig, indexConfig in the payload (they are validated next)","Confirm the endpoint path is the collection root (POST without /{kbId})"],"exampleFix":"// before\ncurl -X POST http://host/knowledge-base\n// (no body -> kb == null)\n\n// after\ncurl -X POST http://host/knowledge-base \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"name\":\"my-kb\",\"processConfig\":{...},\"indexConfig\":{...}}'","handlingStrategy":"validation","validationCode":"if (kb == null) throw new IllegalArgumentException(\"knowledge base request body is required\");","typeGuard":null,"tryCatchPattern":"try {\n    String kbId = kbApi.createKnowledgeBase(kb);\n} catch (BizException e) {\n    if (e.getCode().equals(\"MISSING_PARAMS\")) {\n        // log payload and correct request body\n    } else { throw e; }\n}","preventionTips":["Always send Content-Type: application/json with a JSON body","Never POST the knowledge base collection endpoint with an empty body","Build requests via a typed client model, not hand-written JSON"],"tags":["validation","http-api","spring-boot","missing-parameter","json"],"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"}