{"record":{"id":"8c2bfba4265d64d0","repo":"paperclipai/paperclip","slug":"name-exceeds-the-hard-paperclip-ingestion-cap-o","errorCode":null,"errorMessage":"${name} exceeds the hard Paperclip ingestion cap of ${max} characters.","messagePattern":"(.+?) exceeds the hard Paperclip ingestion cap of (.+?) characters\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugins/plugin-llm-wiki/src/wiki/core.ts","lineNumber":491,"sourceCode":"    requireEnabledProfile: options.requireEnabledProfile,\n  });\n  if (!decision.allowed) throw new Error(decision.message);\n  return decision.space;\n}\n\nfunction assertPaperclipSourceScopePayload(input: { projectId?: string | null; rootIssueId?: string | null }) {\n  if (input.projectId && input.rootIssueId) {\n    throw new Error(\"Paperclip source scope must specify either projectId or rootIssueId, not both.\");\n  }\n}\n\nfunction assertRequestedCharacterLimit(name: string, value: unknown, max: number) {\n  if (value == null) return;\n  if (typeof value !== \"number\" || !Number.isFinite(value) || value < 1) {\n    throw new Error(`${name} must be a positive number.`);\n  }\n  if (Math.floor(value) > max) {\n    throw new Error(`${name} exceeds the hard Paperclip ingestion cap of ${max} characters.`);\n  }\n}\n\nfunction stableSpaceId(input: { companyId: string; wikiId: string; slug: string }): string {\n  const hex = createHash(\"md5\")\n    .update(`${input.companyId}:${input.wikiId}:${input.slug}`)\n    .digest(\"hex\");\n  return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-8${hex.slice(17, 20)}-${hex.slice(20, 32)}`;\n}\n\nfunction normalizeLimit(value: unknown, fallback: number, max: number): number {\n  if (typeof value !== \"number\" || !Number.isFinite(value)) return fallback;\n  return Math.max(1, Math.min(max, Math.floor(value)));\n}\n\nfunction contentHash(contents: string): string {\n  return createHash(\"sha256\").update(contents, \"utf8\").digest(\"hex\");\n}","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/plugin-llm-wiki/src/wiki/core.ts#L473-L509","documentation":"Thrown by assertRequestedCharacterLimit() when the value is a valid positive number but its floored value exceeds the hard cap (max) for that field. The cap is enforced per-field to bound Paperclip ingestion cost; the offending name and the cap are interpolated. This fires after the positivity check, so the value is finite and >= 1 but too large.","triggerScenarios":"Passing maxCharacters above the ingestion cap (e.g. 200000 when the cap is much lower). Requesting an unlimited-ish number that breaches the safety ceiling.","commonSituations":"Caller assumes the hard cap matches some other system's limit. UI lets the user type a large number without a max attribute. Migration from an uncapped API to the capped one.","solutions":["Reduce the requested value to be at or below the cap stated in the error message.","Clamp the value upstream: Math.min(Math.floor(value), cap) before calling — but confirm the clamped value is acceptable semantically.","Surface the cap in the UI so users do not request above it."],"exampleFix":"// before\nassertRequestedCharacterLimit(\"maxCharacters\", 5_000_000, 250_000); // throws\n// after\nassertRequestedCharacterLimit(\"maxCharacters\", 250_000, 250_000);","handlingStrategy":"validation","validationCode":"function clampLimit(name: string, value: number | null | undefined, max: number): number | null {\n  if (value == null) return null;\n  if (typeof value !== \"number\" || !Number.isFinite(value) || value < 1) {\n    throw new Error(`${name} must be a positive number.`);\n  }\n  return Math.min(Math.floor(value), max);\n}","typeGuard":"function withinCap(value: number, max: number): boolean {\n  return Math.floor(value) <= max;\n}","tryCatchPattern":"try {\n  assertRequestedCharacterLimit(\"maxCharacters\", value, MAX_CAP);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"exceeds the hard Paperclip ingestion cap\")) {\n    value = MAX_CAP; // clamp and retry\n  } else throw err;\n}","preventionTips":["Clamp limit values to the documented cap before calling.","Surface the cap in the UI input's max attribute.","Confirm the cap matches the field you are setting (different fields may have different caps)."],"tags":["llm-wiki","validation","numeric","limit","paperclip"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}