{"record":{"id":"faab44177fbd1c74","repo":"anomalyco/sst","slug":"invalid-function-definition-for-the-name-func-faab44","errorCode":null,"errorMessage":"Invalid function definition for the \"${name}\" Function","messagePattern":"Invalid function definition for the \"(.+?)\" Function","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/helpers/function-builder.ts","lineNumber":131,"sourceCode":"              definition.environment,\n            ]).apply(([defaultEnvironment, environment]) => ({\n              ...(defaultEnvironment ?? {}),\n              ...(environment ?? {}),\n            })),\n            permissions: all([\n              defaultArgs?.permissions,\n              definition.permissions,\n            ]).apply(([defaultPermissions, permissions]) => [\n              ...(defaultPermissions ?? []),\n              ...(permissions ?? []),\n            ]),\n          },\n          opts || {},\n        ),\n      );\n      return buildResult(fn);\n    }\n    throw new Error(`Invalid function definition for the \"${name}\" Function`);\n  });\n}\n","sourceCodeStart":113,"sourceCodeEnd":134,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/helpers/function-builder.ts#L113-L134","documentation":"functionBuilder accepts either a function config object or a qualified ARN; if the definition matches neither shape it throws \"Invalid function definition for the <name> Function\". This is a programmer/config error, not a VisibleError, indicating the definition type is unsupported.","triggerScenarios":"Passing a definition that is neither a valid FunctionArgs object nor an ARN string — e.g. undefined, null, an empty object with no handler, or wrong type (number/boolean) to any component that calls functionBuilder.","commonSituations":"Conditional expressions yielding undefined; refactoring that removed the handler field; passing a Pulumi resource object where a raw string or args object was expected.","solutions":["Log/inspect the definition value to confirm its type before building","Provide a valid handler-based config object (handler, runtime, etc.)","Ensure a valid qualified ARN string when referencing an existing function"],"exampleFix":"// before\nconst def: any = process.env.FN // undefined at build time\nnew sst.aws.Function(\"Api\", def)\n// after\nnew sst.aws.Function(\"Api\", { handler: \"src/api.handler\" })","handlingStrategy":"validation","validationCode":"function assertFunctionDef(name: string, def: unknown) {\n  const isArn = typeof def === \"string\" && def.startsWith(\"arn:\");\n  const isConfig = typeof def === \"object\" && def !== null && \"handler\" in (def as any);\n  if (!isArn && !isConfig) throw new Error(`Invalid function definition for \"${name}\"`);\n}","typeGuard":"const isValidFunctionDef = (def: unknown): def is string | { handler: string } =>\n  (typeof def === \"string\" && def.startsWith(\"arn:\")) ||\n  (typeof def === \"object\" && def !== null && \"handler\" in def);","tryCatchPattern":"try { const f = functionBuilder(name, def); } catch (e) { /* report invalid definition shape */ }","preventionTips":["Type definitions as FunctionArgs | string, not any","Check env-driven definitions resolve before build","Keep handler field mandatory in configs"],"tags":["configuration","validation","lambda"],"backgroundTag":"invalid-function-definition","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}