{"record":{"id":"36be18f5b23775b2","repo":"langgenius/dify","slug":"name-exceeds-maximum-size-of-max-list-length","errorCode":null,"errorMessage":"${name} exceeds maximum size of ${MAX_LIST_LENGTH} items","messagePattern":"(.+?) exceeds maximum size of (.+?) items","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"sdks/nodejs-client/src/client/validation.ts","lineNumber":59,"sourceCode":"    throw new ValidationError(`${name} must be an integer when set`)\n  }\n}\n\nexport function ensureOptionalBoolean(value: unknown, name: string): void {\n  if (value === undefined || value === null) {\n    return\n  }\n  if (typeof value !== 'boolean') {\n    throw new ValidationError(`${name} must be a boolean when set`)\n  }\n}\n\nexport function ensureStringArray(value: unknown, name: string): void {\n  if (!Array.isArray(value) || value.length === 0) {\n    throw new ValidationError(`${name} must be a non-empty string array`)\n  }\n  if (value.length > MAX_LIST_LENGTH) {\n    throw new ValidationError(`${name} exceeds maximum size of ${MAX_LIST_LENGTH} items`)\n  }\n  value.forEach((item) => {\n    if (typeof item !== 'string' || item.trim().length === 0) {\n      throw new ValidationError(`${name} must contain non-empty strings`)\n    }\n  })\n}\n\nexport function ensureOptionalStringArray(value: unknown, name: string): void {\n  if (value === undefined || value === null) {\n    return\n  }\n  ensureStringArray(value, name)\n}\n\nexport function ensureRating(value: unknown): void {\n  if (value === undefined || value === null) {\n    return","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/sdks/nodejs-client/src/client/validation.ts#L41-L77","documentation":"Thrown by ensureStringArray() in validation.ts:59 as a ValidationError when the array is valid and non-empty but its length exceeds 1000 (MAX_LIST_LENGTH). The cap defends against oversized batched queries.","triggerScenarios":"Calling kb.listDatasets({ tagIds: hugeArray }) where hugeArray.length > 1000. The non-empty check passes, then the cap check at validation.ts:58 fires.","commonSituations":"Bulk fetching by tag without pagination; concatenating many tag lists; passing an unbounded UI selection directly to the SDK.","solutions":["Batch the request: for (const chunk of chunkArray(tagIds, 1000)) await kb.listDatasets({ tagIds: chunk }).","Reduce the selection upstream; rarely does a real query need >1000 tags.","Validate the size before calling and surface a user-facing error if exceeded."],"exampleFix":"// before\nawait kb.listDatasets({ tagIds: allTags }) // allTags.length === 5000\n\n// after\nfor (const chunk of chunk(allTags, 1000)) {\n  await kb.listDatasets({ tagIds: chunk })\n}","handlingStrategy":"validation","validationCode":"function chunk<T>(arr: T[], size = 1000): T[][] {\n  const out: T[][] = []\n  for (let i = 0; i < arr.length; i += size) out.push(arr.slice(i, i + size))\n  return out\n}","typeGuard":"function isBoundedStringArray(value: unknown, max = 1000): value is string[] {\n  return Array.isArray(value) && value.length <= max\n}","tryCatchPattern":"try {\n  await kb.listDatasets({ tagIds })\n} catch (err) {\n  if (err instanceof Error && /exceeds maximum size/.test(err.message)) {\n    for (const c of chunk(tagIds as string[], 1000)) await kb.listDatasets({ tagIds: c })\n  } else throw err\n}","preventionTips":["Chunk any list field that can grow unbounded.","Add a UI cap on multi-select size.","Log the length of incoming lists before passing to the SDK."],"tags":["validation","length-limit","array","string-array","pagination"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}