{"record":{"id":"25663479d2b9f4b2","repo":"anomalyco/sst","slug":"invalid-function-definition-for-the-name-func","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/function.ts","lineNumber":3112,"sourceCode":"          ...transform(\n            argsTransform,\n            name,\n            {\n              ...definition,\n              ...override,\n              permissions: all([\n                definition.permissions,\n                override?.permissions,\n              ]).apply(([permissions, overridePermissions]) => [\n                ...(permissions ?? []),\n                ...(overridePermissions ?? []),\n              ]),\n            },\n            opts || {},\n          ),\n        );\n      }\n      throw new Error(`Invalid function definition for the \"${name}\" Function`);\n    });\n  }\n\n  /** @internal */\n  public getSSTLink() {\n    return {\n      properties: {\n        name: this.name,\n        url: this.urlEndpoint,\n        ...(this.durable\n          ? {\n              qualifier: this.qualifier,\n            }\n          : {}),\n      },\n      include: [\n        permission({\n          actions: [","sourceCodeStart":3094,"sourceCodeEnd":3130,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/function.ts#L3094-L3130","documentation":"SST's Function component accepts either a function definition object or a string ARN. When a definition entry is neither of these (an entry in a Function list with no matching constructor branch), the component cannot build a Lambda and throws this Error to stop deployment early.","triggerScenarios":"Passing a string that is not recognized as an ARN/reference, or an object that fails the FunctionArgs shape (e.g. missing handler when no bundle provided), or a null/undefined entry in a functions array.","commonSituations":"Typo in the handler path, using a plain object where a Function or its args were expected, migrating from SST v2 config shape to v3, passing the result of a conditional expression that resolves to undefined.","solutions":["Check the value passed for the function: it must be a valid FunctionArgs object with a resolvable handler, or a string ARN of an existing Lambda","Verify the handler file exists at src/<handler>.ts relative to the app and the export name matches","If referencing another Function, pass the Function component instance or its .arn, not an arbitrary string","Log the value just before creating the Function to confirm it is not undefined due to a failed conditional"],"exampleFix":"// before\nnew Function(stack, \"Fn\", undefined as any);\n// after\nnew Function(stack, \"Fn\", { handler: \"src/api.handler\" });","handlingStrategy":"validation","validationCode":"const def = typeof fn === \"string\" ? { arn: fn } : fn;\nif (!def || typeof def !== \"object\" || (!def.handler && !def.arn)) {\n  throw new Error(`Function definition invalid: ${JSON.stringify(def)}`);\n}","typeGuard":"function isFunctionDef(v: unknown): v is { handler: string } {\n  return typeof v === \"object\" && v !== null && \"handler\" in v && typeof (v as any).handler === \"string\";\n}","tryCatchPattern":"try {\n  new sst.aws.Function(stack, name, args);\n} catch (e) {\n  console.error(`Function \"${name}\" rejected definition:`, args);\n  throw e;\n}","preventionTips":["Always pass FunctionArgs objects or Function instances, never undefined/null","Verify handler paths resolve to existing exported functions before deploy","Run sst diff to catch definition issues before deploying","Keep conditional function creation explicit instead of relying on undefined fallbacks"],"tags":["configuration","lambda","sst"],"backgroundTag":"invalid-component-definition","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}