{"record":{"id":"22a25035b7e04aac","repo":"anomalyco/sst","slug":"failed-to-decode-ssm-parameter-value-w","errorCode":null,"errorMessage":"failed to decode SSM parameter value: %w","messagePattern":"failed to decode SSM parameter value: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/project/provider/aws.go","lineNumber":406,"sourceCode":"\t\tssmKey := \"/sst/bootstrap/asset\"\n\t\tgetParamOutput, err := ssmClient.GetParameter(ctx, &ssm.GetParameterInput{\n\t\t\tName: aws.String(ssmKey),\n\t\t})\n\t\tif err != nil {\n\t\t\tvar paramNotFound *ssmTypes.ParameterNotFound\n\t\t\tif errors.As(err, &paramNotFound) {\n\t\t\t\t// Parameter doesn't exist, nothing to do\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\n\t\t// Parameter exists, decode the value\n\t\tvar value struct {\n\t\t\tBucket string `json:\"bucket\"`\n\t\t}\n\t\tif err := json.Unmarshal([]byte(*getParamOutput.Parameter.Value), &value); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to decode SSM parameter value: %w\", err)\n\t\t}\n\n\t\tif value.Bucket != \"\" && value.Bucket != data.Asset {\n\t\t\t// Empty the current asset bucket\n\t\t\tvar continuationToken *string\n\t\t\tfor {\n\t\t\t\tlistObjectsInput := &s3.ListObjectsV2Input{\n\t\t\t\t\tBucket: aws.String(data.Asset),\n\t\t\t\t}\n\t\t\t\tif continuationToken != nil {\n\t\t\t\t\tlistObjectsInput.ContinuationToken = continuationToken\n\t\t\t\t}\n\n\t\t\t\tlistObjectsOutput, err := s3Client.ListObjectsV2(ctx, listObjectsInput)\n\t\t\t\tif err != nil {\n\t\t\t\t\tif strings.Contains(err.Error(), \"NoSuchBucket\") {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/project/provider/aws.go#L388-L424","documentation":"During the old-bootstrap cleanup migration step, SST reads the legacy `/sst/bootstrap/asset` SSM parameter and JSON-decodes its value into a struct with a `bucket` field. If the parameter's value is not valid JSON (or lacks the expected shape), `json.Unmarshal` fails and this error wraps it. It indicates the stored bootstrap metadata is malformed.","triggerScenarios":"Running `sst deploy`/upgrade triggers the cleanup step when `/sst/bootstrap/asset` exists but its value is not valid JSON of `{\"bucket\":\"...\"}` — e.g. manually edited parameter, truncated value, or a value written by a tool other than SST.","commonSituations":"Hand-editing the SSM parameter in the console; an interrupted or partially failed older bootstrap write; another team/tool reusing the same parameter path with non-JSON content.","solutions":["Open the AWS SSM console (or `aws ssm get-parameter --name /sst/bootstrap/asset`) and inspect the value","If the value is not `{\"bucket\":\"<name>\"}` JSON, fix it or delete the parameter — cleanup treats a missing parameter as a no-op and proceeds","Re-run `sst deploy` after correcting/deleting the parameter"],"exampleFix":"// before (corrupt SSM value)\nmy-old-asset-bucket\n// after\n{\"bucket\":\"my-old-asset-bucket\"}","handlingStrategy":"validation","validationCode":"out, err := ssmClient.GetParameter(ctx, &ssm.GetParameterInput{Name: aws.String(\"/sst/bootstrap/asset\")})\nif err == nil {\n    var v struct{ Bucket string `json:\"bucket\"` }\n    if json.Unmarshal([]byte(*out.Parameter.Value), &v) != nil || v.Bucket == \"\" {\n        // malformed metadata: delete the parameter so cleanup treats it as no-op\n        ssmClient.DeleteParameter(ctx, &ssm.DeleteParameterInput{Name: aws.String(\"/sst/bootstrap/asset\")})\n    }\n}","typeGuard":"func isValidBootstrapParam(raw string) bool {\n    var v struct{ Bucket string `json:\"bucket\"` }\n    return json.Unmarshal([]byte(raw), &v) == nil && v.Bucket != \"\"\n}","tryCatchPattern":null,"preventionTips":["Never hand-edit /sst/bootstrap/* SSM parameters","Keep the parameter value strictly as {\"bucket\":\"...\"} JSON","Delete the parameter instead of blanking it when cleaning up manually"],"tags":["aws","ssm","json","bootstrap-migration"],"backgroundTag":"json-decode-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}