Crosstalk-Solutions/project-nomad · warning

oldName and newName are required.

Error message

oldName and newName are required.

What it means

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.

Source

Thrown at admin/app/controllers/rag_controller.ts:102

    const collection = sanitizeCollectionName(request.input('collection', null))

    if (!source) {
      return response.status(400).json({ error: 'source is required.' })
    }

    const result = await this.ragService.updateFileCollection(source, collection)
    if (!result.success) {
      return response.status(500).json({ error: result.message })
    }
    return response.status(200).json({ message: result.message })
  }

  public async renameKnowledgeCollection({ request, response }: HttpContext) {
    const oldName = sanitizeCollectionName(request.input('oldName', null))
    const newName = sanitizeCollectionName(request.input('newName', null))

    if (!oldName || !newName) {
      return response.status(400).json({ error: 'oldName and newName are required.' })
    }

    const result = await this.ragService.renameKnowledgeCollection(oldName, newName)
    if (!result.success) {
      return response.status(500).json({ error: result.message })
    }
    return response.status(200).json({ message: result.message })
  }

  public async deleteKnowledgeCollection({ request, response }: HttpContext) {
    const name = sanitizeCollectionName(request.input('name', null))

    if (!name) {
      return response.status(400).json({ error: 'name is required.' })
    }

    const result = await this.ragService.deleteKnowledgeCollection(name)
    if (!result.success) {

View on GitHub (pinned to 0bd1c6f4f9)

Solutions

  1. Send both oldName and newName as non-empty strings in the request body.
  2. Check the client field names match exactly (oldName/newName, not old_name/new_name).
  3. Trim/validate input before submitting; ensure sanitizeCollectionName accepts the format (alphanumeric, dashes, underscores).

Example fix

// before
await fetch('/api/rag/collections/rename', { method: 'POST', body: JSON.stringify({ oldName: 'docs' }) })
// after
await fetch('/api/rag/collections/rename', { method: 'POST', body: JSON.stringify({ oldName: 'docs', newName: 'docs-v2' }) })
Defensive patterns

Strategy: validation

Validate before calling

const oldName = String(req.oldName ?? '').trim()
const newName = String(req.newName ?? '').trim()
if (!oldName || !newName) throw new BadRequest('oldName and newName are required')

Type guard

const isRenamePayload = (b: unknown): b is { oldName: string; newName: string } =>
  !!b && typeof (b as any).oldName === 'string' && (b as any).oldName.trim() !== '' &&
     typeof (b as any).newName === 'string' && (b as any).newName.trim() !== ''

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of Crosstalk-Solutions/project-nomad@0bd1c6f4f9 (2026-08-27). Data as JSON: /api/errors/0ac9a60f60f993ed. Report an issue: GitHub.