{"record":{"id":"ff28f8d129caed12","repo":"linshenkx/prompt-optimizer","slug":"requirements-must-not-exceed-10-000-characters","errorCode":null,"errorMessage":"Requirements must not exceed 10,000 characters","messagePattern":"Requirements must not exceed 10,000 characters","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mcp-server/src/adapters/parameter-adapter.ts","lineNumber":37,"sourceCode":"\n  /**\n   * 验证模板输入\n   */\n  static validateTemplate(template?: string): void {\n    if (template !== undefined && (typeof template !== 'string' || template.trim().length === 0)) {\n      throw new Error('Template must be a non-empty string');\n    }\n  }\n\n  /**\n   * 验证需求描述输入\n   */\n  static validateRequirements(requirements: string): void {\n    if (!requirements || typeof requirements !== 'string' || requirements.trim().length === 0) {\n      throw new Error('Requirements must be a non-empty string');\n    }\n    if (requirements.length > 10000) {\n      throw new Error('Requirements must not exceed 10,000 characters');\n    }\n  }\n}\n","sourceCodeStart":19,"sourceCodeEnd":41,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/mcp-server/src/adapters/parameter-adapter.ts#L19-L41","documentation":"ParameterAdapter.validateRequirements throws this when requirements.length exceeds 10,000 characters — a hard cap on the requirements/description input, tighter than the prompt limit (50,000).","triggerScenarios":"Calling a requirements-based tool with a requirements string over 10,000 characters, e.g. pasting a full PRD or spec document into the requirements field.","commonSituations":"Inlining entire specification documents rather than a summary; concatenating ticket descriptions plus acceptance criteria plus comments; assuming the requirements limit matches the prompt limit (it's 5x smaller).","solutions":["Summarize requirements to under 10,000 characters before the call","Put the detailed spec in the prompt (50k limit) and keep requirements as a concise statement","Chunk long specs across multiple calls"],"exampleFix":"// before\nawait tool.call({ requirements: fullPrd });\n\n// after\nawait tool.call({ requirements: fullPrd.slice(0, 10000), prompt: fullPrd });","handlingStrategy":"validation","validationCode":"const MAX_REQ = 10000;\nif (requirements.length > MAX_REQ) requirements = requirements.slice(0, MAX_REQ);","typeGuard":"const isWithinRequirementsLimit = (r: string): boolean => r.length <= 10000;","tryCatchPattern":"try { await call({ requirements }); } catch (e) { if ((e as Error).message.includes('10,000')) { await call({ requirements: requirements.slice(0, 10000) }); } else throw e; }","preventionTips":["Remember the requirements limit (10k) is lower than the prompt limit (50k)","Summarize long specs; move detail into the prompt field"],"tags":["validation","input-validation","requirements","limit"],"backgroundTag":"request-payload-too-large","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}