{"record":{"id":"ec69d66a99b97081","repo":"serverless/serverless","slug":"toolschema-must-be-a-file-path-string-or-array-of","errorCode":null,"errorMessage":"toolSchema must be a file path string or array of tool definitions","messagePattern":"toolSchema must be a file path string or array of tool definitions","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/serverless/lib/plugins/aws/bedrock-agentcore/compilers/gatewayTarget.js","lineNumber":269,"sourceCode":"      })),\n    }\n  }\n\n  // Inline array\n  if (Array.isArray(toolSchema)) {\n    return {\n      InlinePayload: toolSchema.map((tool) => ({\n        Name: tool.name,\n        Description: tool.description,\n        InputSchema: transformSchemaToCloudFormation(tool.inputSchema),\n        ...(tool.outputSchema && {\n          OutputSchema: transformSchemaToCloudFormation(tool.outputSchema),\n        }),\n      })),\n    }\n  }\n\n  throw new Error(\n    'toolSchema must be a file path string or array of tool definitions',\n  )\n}\n\n/**\n * Build Lambda target configuration\n * New syntax: { function: 'functionName' | { name, arn }, toolSchema: [...] | 'file.json' }\n */\nexport function buildLambdaTarget(config, serviceDir) {\n  const lambdaArn = resolveFunctionArn(config.function)\n  const toolSchema = resolveToolSchema(config.toolSchema, serviceDir)\n\n  return {\n    Mcp: {\n      Lambda: {\n        LambdaArn: lambdaArn,\n        ToolSchema: toolSchema,\n      },","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/serverless/serverless/blob/b9d7ea51c8cce57cff1207964b9b71123673081f/packages/serverless/lib/plugins/aws/bedrock-agentcore/compilers/gatewayTarget.js#L251-L287","documentation":"resolveToolSchema() only accepts two shapes for toolSchema: a string (file path) or an array (inline tool definitions). Any other type (number, plain object, boolean) reaches the terminal throw at the end of the function.","triggerScenarios":"toolSchema set to a single inline tool object instead of an array; a numeric or boolean value; an object that should have been a file-path string.","commonSituations":"User wraps a single tool in {} instead of [{}]; passes a YAML mapping where the schema expects a list.","solutions":["If inline, wrap the tool(s) in an array: toolSchema: [ { ... } ].","If referencing a file, use a string path.","Do not pass a single object, number, or boolean as toolSchema."],"exampleFix":"# before\ntoolSchema:\n  name: doThing\n  description: x\n  inputSchema: { type: object }\n# after\ntoolSchema:\n  - name: doThing\n    description: x\n    inputSchema:\n      type: object","handlingStrategy":"type-guard","validationCode":"if (typeof toolSchema !== 'string' && !Array.isArray(toolSchema)) {\n  throw new Error('toolSchema must be a string file path or an array of tool definitions');\n}","typeGuard":"function isToolSchema(v) {\n  return typeof v === 'string' || Array.isArray(v);\n}","tryCatchPattern":null,"preventionTips":["Always wrap a single inline tool in an array.","Use the framework's config schema to enforce array-or-string.","Add a fixture in tests for the single-object case to catch regressions."],"tags":["bedrock-agentcore","tool-schema","validation","types"],"backgroundTag":null,"analyzedSha":"b9d7ea51c8cce57cff1207964b9b71123673081f","analyzedAt":"2026-08-13T04:14:40.386Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}