{"record":{"id":"c401efce6c6631a9","repo":"alibaba/spring-ai-alibaba","slug":"missing-params-c401ef","errorCode":"MISSING_PARAMS","errorMessage":"kbId","messagePattern":"kbId","errorType":"validation","errorClass":"BizException","httpStatus":null,"severity":"warning","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/controller/DocumentController.java","lineNumber":70,"sourceCode":"\tprivate final DocumentService documentService;\n\n\tpublic DocumentController(DocumentService documentService) {\n\t\tthis.documentService = documentService;\n\t}\n\n\t/**\n\t * Creates new documents in the knowledge base\n\t * @param kbId Knowledge base ID\n\t * @param request Document creation request\n\t * @return Created document IDs\n\t */\n\t@PostMapping(value = \"/{kbId}/documents\")\n\tpublic Result<List<String>> createDocuments(@PathVariable(\"kbId\") String kbId,\n\t\t\t@RequestBody CreateDocumentRequest request) {\n\t\tRequestContext context = RequestContextHolder.getRequestContext();\n\n\t\tif (Objects.isNull(kbId)) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"kbId\"));\n\t\t}\n\n\t\tif (Objects.isNull(request.getType())) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"type\"));\n\t\t}\n\n\t\tif (CollectionUtils.isEmpty(request.getFiles())) {\n\t\t\tthrow new BizException(ErrorCode.MISSING_PARAMS.toError(\"files\"));\n\t\t}\n\n\t\trequest.setKbId(kbId);\n\t\tList<String> docIds = documentService.createDocuments(request);\n\t\treturn Result.success(context.getRequestId(), docIds);\n\t}\n\n\t/**\n\t * Updates an existing document\n\t * @param kbId Knowledge base ID","sourceCodeStart":52,"sourceCodeEnd":88,"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/DocumentController.java#L52-L88","documentation":"BizException(ErrorCode.MISSING_PARAMS.toError(\"kbId\")) is thrown by DocumentController.createDocuments (POST /{kbId}/documents) when the kbId path variable is null. The knowledge-base id is required so the uploaded files are attached to the right KB; the controller rejects a null id before validating the rest of the request. Normally the route guarantees the value, so a null indicates direct invocation.","triggerScenarios":"Invoking the create-documents handler with a null kbId argument — via direct method call in tests or programmatic invocation; the HTTP route itself always contains the path segment.","commonSituations":"Controller unit tests with null path variables; reflection-based callers; generated client stubs that fail to substitute the kbId placeholder.","solutions":["POST the documents to a concrete knowledge base path, e.g. POST /{kbId}/documents with kbId filled in","In direct calls, pass the real kbId string instead of null","Catch BizException MISSING_PARAMS and ask the caller for a valid knowledge-base id"],"exampleFix":"// before\ncontroller.createDocuments(null, createRequest);\n// after\ncontroller.createDocuments(\"kb-123\", createRequest);","handlingStrategy":"validation","validationCode":"if (kbId == null || kbId.isBlank()) {\n  throw new IllegalArgumentException('kbId is required in the URL path to create documents');\n}","typeGuard":"function hasKbId(route) {\n  return typeof route.kbId === 'string' && route.kbId.trim().length > 0;\n}","tryCatchPattern":"try {\n  return documentApi.createDocuments(kbId, request);\n} catch (BizException e) {\n  if (\"MISSING_PARAMS\".equals(e.getCode())) {\n    throw new ClientValidationError(\"kbId path variable is required: \" + e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Resolve the target knowledge base before initiating a document upload","Use a URL builder that throws when kbId is missing instead of substituting 'null'","In tests, pass concrete kbId values to handler methods"],"tags":["validation","http-api","path-variable"],"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"}