langgenius/dify · error · ValidationError
Parameter '${key}' exceeds maximum size of ${MAX_DICT_LENGTH
Error message
Parameter '${key}' exceeds maximum size of ${MAX_DICT_LENGTH} items What it means
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.
Source
Thrown at sdks/nodejs-client/src/client/validation.ts:107
// Only check max length for strings; empty strings are allowed for optional params
// Required fields are validated at method level via ensureNonEmptyString
if (typeof value === 'string') {
if (value.length > MAX_STRING_LENGTH) {
throw new ValidationError(
`Parameter '${key}' exceeds maximum length of ${MAX_STRING_LENGTH} characters`,
)
}
} else if (Array.isArray(value)) {
if (value.length > MAX_LIST_LENGTH) {
throw new ValidationError(
`Parameter '${key}' exceeds maximum size of ${MAX_LIST_LENGTH} items`,
)
}
} else if (isRecord(value)) {
if (Object.keys(value).length > MAX_DICT_LENGTH) {
throw new ValidationError(
`Parameter '${key}' exceeds maximum size of ${MAX_DICT_LENGTH} items`,
)
}
}
if (key === 'user' && typeof value !== 'string') {
throw new ValidationError(`Parameter '${key}' must be a string`)
}
if ((key === 'page' || key === 'limit' || key === 'page_size') && !Number.isInteger(value)) {
throw new ValidationError(`Parameter '${key}' must be an integer`)
}
if (key === 'files' && !Array.isArray(value) && typeof value !== 'object') {
throw new ValidationError(`Parameter '${key}' must be a list or dict`)
}
if (key === 'rating' && value !== 'like' && value !== 'dislike') {
throw new ValidationError(`Parameter '${key}' must be 'like' or 'dislike'`)
}
})
}View on GitHub (pinned to ef8544b173)
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.
Example fix
// before
await client.chat('fx', { query, user, inputs: entireFeatureFlagMap })
// after
const inputs = Object.fromEntries(
Object.entries(entireFeatureFlagMap).slice(0, 100)
)
await client.chat('fx', { query, user, inputs }) Defensive patterns
Strategy: validation
Validate before calling
const MAX_DICT_LENGTH = 100
function assertBoundedDicts(params: Record<string, unknown>) {
for (const [k, v] of Object.entries(params)) {
if (v !== null && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).length > MAX_DICT_LENGTH) {
throw new Error(`Parameter '${k}' exceeds ${MAX_DICT_LENGTH} keys`)
}
}
} Type guard
function isBoundedDictParams(params: Record<string, unknown>, max = 100): boolean {
return Object.values(params).every((v) => {
if (v === null || typeof v !== 'object' || Array.isArray(v)) return true
return Object.keys(v).length <= max
})
} Try / catch
try {
await client.chat('fx', payload)
} catch (err) {
if (err instanceof Error && /exceeds maximum size/.test(err.message) && /items/.test(err.message)) {
// reduce inputs dict and retry
} else throw err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Passing a large dynamic metadata dict; UI-generated configs with many optional keys; serializing feature flags into inputs.
Related errors
- Parameter '${key}' exceeds maximum length of ${MAX_STRING_LE
- ${name} exceeds maximum length of ${MAX_STRING_LENGTH} chara
- Parameter '${key}' exceeds maximum size of ${MAX_LIST_LENGTH
- Parameter '${key}' must be a string
- Parameter '${key}' must be an integer
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/f4b1748a2de9f01d.
Report an issue: GitHub.