{"record":{"id":"e62e13478f5bc2d4","repo":"anomalyco/sst","slug":"lifecycle-rule-at-index-index-has-an-empty-or-w","errorCode":null,"errorMessage":"Lifecycle rule at index ${index} has an empty or whitespace-only \"id\". Please provide a valid id or omit it to use the auto-generated id.","messagePattern":"Lifecycle rule at index (.+?) has an empty or whitespace-only \"id\"\\. Please provide a valid id or omit it to use the auto-generated id\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/bucket.ts","lineNumber":971,"sourceCode":"            },\n            { parent },\n          ),\n        );\n      });\n    }\n\n    function createLifecycle() {\n      return output(args.lifecycle).apply((lifecycleRules) => {\n        if (!lifecycleRules || lifecycleRules.length === 0) return;\n\n        const seenIds = new Map<string, number>();\n\n        const resolvedIds = lifecycleRules.map((rule, index) => {\n          const rawId = rule.id ?? `${name}LifecycleRule${index}`;\n          const resolvedId = rawId.trim();\n\n          if (resolvedId.length === 0) {\n            throw new VisibleError(\n              `Lifecycle rule at index ${index} has an empty or whitespace-only \"id\". Please provide a valid id or omit it to use the auto-generated id.`,\n            );\n          }\n\n          if (resolvedId.length > 255) {\n            throw new VisibleError(\n              `Lifecycle rule at index ${index} has an \"id\" that is ${resolvedId.length} characters long. AWS S3 lifecycle rule IDs cannot exceed 255 characters.`,\n            );\n          }\n\n          const existingIndex = seenIds.get(resolvedId);\n          if (existingIndex !== undefined) {\n            throw new VisibleError(\n              `Lifecycle rule \"id\" values must be unique. The id \"${resolvedId}\" is used by rules at indexes ${existingIndex} and ${index}.`,\n            );\n          }\n          seenIds.set(resolvedId, index);\n","sourceCodeStart":953,"sourceCodeEnd":989,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/bucket.ts#L953-L989","documentation":"S3 lifecycle rule IDs must be non-empty, and SST additionally rejects whitespace-only IDs. When a lifecycle rule's `id` trims to an empty string, SST throws this VisibleError because S3 would reject it and auto-generated IDs are the intended default. Omitting `id` entirely lets SST generate `${name}LifecycleRule${index}`.","triggerScenarios":"Passing a lifecycle rule in `bucket.transform` or lifecycle args with `id: \"\"` or `id: \"   \"` (whitespace only).","commonSituations":"Setting `id` from an env var or user config that is blank; building rule objects programmatically with an uninitialized id field; trimming user input without checking emptiness before assigning.","solutions":["Omit the `id` field so SST auto-generates a valid ID","Provide a meaningful non-empty, non-whitespace id for the rule","Validate/trim the id source (env var, config) upstream and fall back to omitting it when empty"],"exampleFix":"// before\ntransform: {\n  bucket: { lifecycleRules: [{ id: \"\", status: \"Enabled\", expiration: { days: 30 } }] }\n}\n// after\ntransform: {\n  bucket: { lifecycleRules: [{ status: \"Enabled\", expiration: { days: 30 } }] }\n}","handlingStrategy":"validation","validationCode":"rules.forEach((r, i) => {\n  if (r.id != null && r.id.trim() === \"\") {\n    delete r.id; // fall back to auto-generated id\n  }\n});","typeGuard":"function hasValidLifecycleId(r: { id?: string }): boolean {\n  return r.id === undefined || r.id.trim().length > 0;\n}","tryCatchPattern":"try {\n  new sst.aws.Bucket(\"B\", { transform: { bucket: { lifecycleRules: rules } } });\n} catch (e) {\n  if ((e as Error).message.includes(\"empty or whitespace-only\")) {\n    console.error(\"Fix or drop the empty lifecycle rule id\");\n  }\n  throw e;\n}","preventionTips":["Omit `id` rather than passing an empty string; SST auto-generates one","Trim and validate any id sourced from env vars or external config","Keep lifecycle rule definitions in typed, reviewed config modules"],"tags":["aws","s3","lifecycle-rule","validation"],"backgroundTag":"invalid-resource-id","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}