{"record":{"id":"3a94974ee21fc8a0","repo":"langgenius/dify","slug":"parameter-key-exceeds-maximum-size-of-max-l","errorCode":null,"errorMessage":"Parameter '${key}' exceeds maximum size of ${MAX_LIST_LENGTH} items","messagePattern":"Parameter '(.+?)' exceeds maximum size of (.+?) items","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"sdks/nodejs-client/src/client/validation.ts","lineNumber":101,"sourceCode":"\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`)\n    }\n    if ((key === 'page' || key === 'limit' || key === 'page_size') && !Number.isInteger(value)) {\n      throw new ValidationError(`Parameter '${key}' must be an integer`)\n    }\n    if (key === 'files' && !Array.isArray(value) && typeof value !== 'object') {\n      throw new ValidationError(`Parameter '${key}' must be a list or dict`)","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/sdks/nodejs-client/src/client/validation.ts#L83-L119","documentation":"Thrown by validateParams() in validation.ts:101 as a ValidationError. Any array-valued query or body param exceeding 1000 items (MAX_LIST_LENGTH) is rejected in the HTTP layer. The key name is interpolated.","triggerScenarios":"Any request carrying an array field with > 1000 elements in query or record body — e.g. lists of ids, batched inputs, tag arrays. Triggered from client.ts request() before the HTTP call.","commonSituations":"Bulk operations sending an unbounded list; aggregating many selection items without chunking; passing a corpus slice in one shot.","solutions":["Chunk the array and make multiple requests: for (const c of chunk(arr, 1000)) await client....(c).","Move the bulk payload to a dedicated batch endpoint or upload flow if available.","Validate size before the call and surface a domain-specific error."],"exampleFix":"// before\nawait client.chat('fx', { query, user, inputs: { ids: allIds } }) // >1000\n\n// after\nfor (const chunk of chunkArray(allIds, 1000)) {\n  await client.chat('fx', { query, user, inputs: { ids: chunk } })\n}","handlingStrategy":"validation","validationCode":"const MAX_LIST_LENGTH = 1000\nfunction assertBoundedArrays(params: Record<string, unknown>) {\n  for (const [k, v] of Object.entries(params)) {\n    if (Array.isArray(v) && v.length > MAX_LIST_LENGTH) {\n      throw new Error(`Parameter '${k}' exceeds ${MAX_LIST_LENGTH} items; chunk it`)\n    }\n  }\n}","typeGuard":"function isBoundedArrayParams(params: Record<string, unknown>, max = 1000): boolean {\n  return Object.values(params).every((v) => !Array.isArray(v) || v.length <= max)\n}","tryCatchPattern":"try {\n  await client.chat('fx', payload)\n} catch (err) {\n  if (err instanceof Error && /exceeds maximum size/.test(err.message) && /items/.test(err.message)) {\n    // chunk the offending array and loop\n  } else throw err\n}","preventionTips":["Chunk large array params before the call.","Prefer dedicated batch endpoints when available.","Cap UI multi-selects at a reasonable size."],"tags":["validation","length-limit","array","http","pagination"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}