{"record":{"id":"f4b1748a2de9f01d","repo":"langgenius/dify","slug":"parameter-key-exceeds-maximum-size-of-max-d","errorCode":null,"errorMessage":"Parameter '${key}' exceeds maximum size of ${MAX_DICT_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":107,"sourceCode":"\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`)\n    }\n    if (key === 'rating' && value !== 'like' && value !== 'dislike') {\n      throw new ValidationError(`Parameter '${key}' must be 'like' or 'dislike'`)\n    }\n  })\n}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/sdks/nodejs-client/src/client/validation.ts#L89-L125","documentation":"Thrown by validateParams() in validation.ts:107 as a ValidationError. Any record/object-valued query or body param with more than 100 keys (MAX_DICT_LENGTH) is rejected. The key name is interpolated.","triggerScenarios":"Calling an endpoint with an inputs object, metadata object, or config object containing > 100 keys. Triggered from the HTTP-layer validateParams via isRecord() at validation.ts:104.","commonSituations":"Passing a large dynamic metadata dict; UI-generated configs with many optional keys; serializing feature flags into inputs.","solutions":["Reduce the dict to only the keys the server consumes; prune unknown or unused fields.","Move large structured data to a dedicated storage endpoint and reference it by id.","Validate Object.keys(value).length upstream and warn the caller."],"exampleFix":"// before\nawait client.chat('fx', { query, user, inputs: entireFeatureFlagMap })\n\n// after\nconst inputs = Object.fromEntries(\n  Object.entries(entireFeatureFlagMap).slice(0, 100)\n)\nawait client.chat('fx', { query, user, inputs })","handlingStrategy":"validation","validationCode":"const MAX_DICT_LENGTH = 100\nfunction assertBoundedDicts(params: Record<string, unknown>) {\n  for (const [k, v] of Object.entries(params)) {\n    if (v !== null && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).length > MAX_DICT_LENGTH) {\n      throw new Error(`Parameter '${k}' exceeds ${MAX_DICT_LENGTH} keys`)\n    }\n  }\n}","typeGuard":"function isBoundedDictParams(params: Record<string, unknown>, max = 100): boolean {\n  return Object.values(params).every((v) => {\n    if (v === null || typeof v !== 'object' || Array.isArray(v)) return true\n    return Object.keys(v).length <= max\n  })\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    // reduce inputs dict and retry\n  } else throw err\n}","preventionTips":["Send only the keys the server actually consumes.","Store large structured data externally and reference by id.","Audit dynamic dicts for accumulated keys before sending."],"tags":["validation","length-limit","dict","object","http","guard"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}