{"record":{"id":"5534add7633acc79","repo":"langgenius/dify","slug":"parameter-key-exceeds-maximum-length-of-max","errorCode":null,"errorMessage":"Parameter '${key}' exceeds maximum length of ${MAX_STRING_LENGTH} characters","messagePattern":"Parameter '(.+?)' exceeds maximum length of (.+?) characters","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"sdks/nodejs-client/src/client/validation.ts","lineNumber":95,"sourceCode":"    return\n  }\n  if (value !== 'like' && value !== 'dislike') {\n    throw new ValidationError(\"rating must be either 'like' or 'dislike'\")\n  }\n}\n\nexport function validateParams(params: Record<string, unknown>): void {\n  Object.entries(params).forEach(([key, value]) => {\n    if (value === undefined || value === null) {\n      return\n    }\n\n    // Only check max length for strings; empty strings are allowed for optional params\n    // Required fields are validated at method level via ensureNonEmptyString\n    if (typeof value === 'string') {\n      if (value.length > MAX_STRING_LENGTH) {\n        throw new ValidationError(\n          `Parameter '${key}' exceeds maximum length of ${MAX_STRING_LENGTH} characters`,\n        )\n      }\n    } else if (Array.isArray(value)) {\n      if (value.length > MAX_LIST_LENGTH) {\n        throw new ValidationError(\n          `Parameter '${key}' exceeds maximum size of ${MAX_LIST_LENGTH} items`,\n        )\n      }\n    } else if (isRecord(value)) {\n      if (Object.keys(value).length > MAX_DICT_LENGTH) {\n        throw new ValidationError(\n          `Parameter '${key}' exceeds maximum size of ${MAX_DICT_LENGTH} items`,\n        )\n      }\n    }\n\n    if (key === 'user' && typeof value !== 'string') {\n      throw new ValidationError(`Parameter '${key}' must be a string`)","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/sdks/nodejs-client/src/client/validation.ts#L77-L113","documentation":"Thrown by validateParams() in validation.ts:95 as a ValidationError. Unlike the named guards, validateParams runs in the HTTP layer (client.ts:490/494) over every query and record body param. Any string value (regardless of key) longer than 10000 characters is rejected. The key name is interpolated into the message.","triggerScenarios":"Any request whose query or JSON body contains a string field > 10000 chars: chat messages, prompts, document text passed inline, or accidentally huge identifiers. Triggered from client.ts:489 (query) or client.ts:493 (body) for record-shaped data.","commonSituations":"Passing full document text as a query param instead of using the upload flow; large prompts in a chat request that exceed the cap; concatenated context windows.","solutions":["Move large content to the proper endpoint: use document upload + reference rather than inline text in a query.","Truncate or summarize the field upstream to stay under 10000 chars.","Inspect the error's interpolated `${key}` to identify which param is oversized and restructure that call."],"exampleFix":"// before\nawait client.chat('fx', { query, user, inputs: { doc: fullText } }) // fullText > 10000\n\n// after\nconst docId = await kb.createDocumentByText(ds, { name, text: fullText }, user)\nawait client.chat('fx', { query, user, inputs: { doc_id: docId } })","handlingStrategy":"validation","validationCode":"const MAX_STRING_LENGTH = 10000\nfunction clampStringParams(params: Record<string, unknown>) {\n  for (const [k, v] of Object.entries(params)) {\n    if (typeof v === 'string' && v.length > MAX_STRING_LENGTH) {\n      throw new Error(`Parameter '${k}' too long; move to upload endpoint`)\n    }\n  }\n}","typeGuard":"function isBoundedStringParams(params: Record<string, unknown>, max = 10000): boolean {\n  return Object.values(params).every((v) => typeof v !== 'string' || v.length <= max)\n}","tryCatchPattern":"try {\n  await client.chat('fx', payload)\n} catch (err) {\n  if (err instanceof Error && /exceeds maximum length/.test(err.message)) {\n    // extract the offending key, move to file upload, retry\n  } else throw err\n}","preventionTips":["Route document-sized content through the upload/document endpoints, not inline params.","Log param lengths in dev to catch accidental bloat.","Schema-validate request bodies before they reach the SDK."],"tags":["validation","length-limit","http","query","body","guard"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}