{"record":{"id":"0ac9a60f60f993ed","repo":"Crosstalk-Solutions/project-nomad","slug":"oldname-and-newname-are-required","errorCode":null,"errorMessage":"oldName and newName are required.","messagePattern":"oldName and newName are required\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"admin/app/controllers/rag_controller.ts","lineNumber":102,"sourceCode":"    const collection = sanitizeCollectionName(request.input('collection', null))\n\n    if (!source) {\n      return response.status(400).json({ error: 'source is required.' })\n    }\n\n    const result = await this.ragService.updateFileCollection(source, collection)\n    if (!result.success) {\n      return response.status(500).json({ error: result.message })\n    }\n    return response.status(200).json({ message: result.message })\n  }\n\n  public async renameKnowledgeCollection({ request, response }: HttpContext) {\n    const oldName = sanitizeCollectionName(request.input('oldName', null))\n    const newName = sanitizeCollectionName(request.input('newName', null))\n\n    if (!oldName || !newName) {\n      return response.status(400).json({ error: 'oldName and newName are required.' })\n    }\n\n    const result = await this.ragService.renameKnowledgeCollection(oldName, newName)\n    if (!result.success) {\n      return response.status(500).json({ error: result.message })\n    }\n    return response.status(200).json({ message: result.message })\n  }\n\n  public async deleteKnowledgeCollection({ request, response }: HttpContext) {\n    const name = sanitizeCollectionName(request.input('name', null))\n\n    if (!name) {\n      return response.status(400).json({ error: 'name is required.' })\n    }\n\n    const result = await this.ragService.deleteKnowledgeCollection(name)\n    if (!result.success) {","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/Crosstalk-Solutions/project-nomad/blob/0bd1c6f4f9888d577fe232de06ac144bb8337131/admin/app/controllers/rag_controller.ts#L84-L120","documentation":"Validation error returned by the RAG admin controller when renaming a knowledge collection: the request body must include both oldName and newName, and each must survive sanitizeCollectionName (non-empty after trimming/normalization). It is a 400 client error, not a library exception.","triggerScenarios":"POST to the rename knowledge collection endpoint with a missing oldName or newName, an empty string, or a value that sanitizeCollectionName reduces to null (e.g. only whitespace or invalid characters).","commonSituations":"Frontend form submitting before both fields are filled; whitespace-only input; field name casing mismatch (old_name vs oldName); JSON body not parsed so inputs are undefined.","solutions":["Send both oldName and newName as non-empty strings in the request body.","Check the client field names match exactly (oldName/newName, not old_name/new_name).","Trim/validate input before submitting; ensure sanitizeCollectionName accepts the format (alphanumeric, dashes, underscores)."],"exampleFix":"// before\nawait fetch('/api/rag/collections/rename', { method: 'POST', body: JSON.stringify({ oldName: 'docs' }) })\n// after\nawait fetch('/api/rag/collections/rename', { method: 'POST', body: JSON.stringify({ oldName: 'docs', newName: 'docs-v2' }) })","handlingStrategy":"validation","validationCode":"const oldName = String(req.oldName ?? '').trim()\nconst newName = String(req.newName ?? '').trim()\nif (!oldName || !newName) throw new BadRequest('oldName and newName are required')","typeGuard":"const isRenamePayload = (b: unknown): b is { oldName: string; newName: string } =>\n  !!b && typeof (b as any).oldName === 'string' && (b as any).oldName.trim() !== '' &&\n     typeof (b as any).newName === 'string' && (b as any).newName.trim() !== ''","tryCatchPattern":null,"preventionTips":["Validate both fields client-side before submit","Disable rename button until both fields are non-empty"],"tags":["validation","request-body","adonisjs","rag"],"backgroundTag":"missing-required-request-field","analyzedSha":"0bd1c6f4f9888d577fe232de06ac144bb8337131","analyzedAt":"2026-08-27T05:34:15.424Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}