{"record":{"id":"f55eb08ce4c4bbce","repo":"apache/beam","slug":"error-loading-aws-config-v","errorCode":null,"errorMessage":"error loading AWS config: %v","messagePattern":"error loading AWS config: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sdks/go/pkg/beam/io/filesystem/s3/s3.go","lineNumber":45,"sourceCode":"\t\"github.com/apache/beam/sdks/v2/go/pkg/beam/util/fsx\"\n\t\"github.com/aws/aws-sdk-go-v2/aws\"\n\t\"github.com/aws/aws-sdk-go-v2/config\"\n\t\"github.com/aws/aws-sdk-go-v2/service/s3\"\n)\n\nfunc init() {\n\tfilesystem.Register(\"s3\", New)\n}\n\ntype fs struct {\n\tclient *s3.Client\n}\n\n// New creates a new S3 filesystem using AWS default configuration sources.\nfunc New(ctx context.Context) filesystem.Interface {\n\tcfg, err := config.LoadDefaultConfig(ctx)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"error loading AWS config: %v\", err))\n\t}\n\n\tclient := s3.NewFromConfig(cfg)\n\treturn &fs{client: client}\n}\n\n// Close closes the filesystem.\nfunc (f *fs) Close() error {\n\treturn nil\n}\n\n// List returns a slice of the files in the filesystem that match the glob pattern.\nfunc (f *fs) List(ctx context.Context, glob string) ([]string, error) {\n\tbucket, keyPattern, err := parseURI(glob)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing S3 uri: %v\", err)\n\t}\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/filesystem/s3/s3.go#L27-L63","documentation":"s3.New panics if the AWS SDK's config.LoadDefaultConfig fails to assemble a configuration from the default chain (env vars, shared credentials/config files, EC2/ECS metadata). Without a valid config the SDK cannot construct an S3 client, so the filesystem constructor fails fast. This surfaces credential/provider initialization problems, not S3 request failures.","triggerScenarios":"Calling filesystem/s3.New(ctx) with malformed AWS_* environment variables (e.g. unparseable AWS_PROFILE or invalid AWS_CONFIG_FILE), or a shared credentials file unreadable/corrupt so LoadDefaultConfig returns an error.","commonSituations":"Containers missing IAM role metadata; mis-set AWS_CONFIG_FILE pointing to a directory; AWS_PROFILE referencing a profile absent from ~/.aws/config.","solutions":["Check AWS_* env vars and the shared credentials/config files (~/.aws/credentials, ~/.aws/config) for validity","Verify AWS_PROFILE names an existing profile","Ensure AWS_CONFIG_FILE / AWS_SHARED_CREDENTIALS_FILE point to readable files","Replace the default chain with explicit config: config.LoadDefaultConfig(ctx, config.WithSharedConfigProfile(\"name\")) and handle the error yourself instead of panicking"],"exampleFix":"// before\nfs := s3.New(ctx)\n// after\ncfg, err := config.LoadDefaultConfig(ctx)\nif err != nil {\n    log.Fatalf(\"AWS config error: %v\", err)\n}\nclient := s3.NewFromConfig(cfg)","handlingStrategy":"try-catch","validationCode":"// Pre-flight: run config.LoadDefaultConfig yourself at startup and fail with a clear message.\ncfg, err := config.LoadDefaultConfig(ctx)\nif err != nil { return fmt.Errorf(\"AWS config: %w\", err) }","typeGuard":null,"tryCatchPattern":"defer func() { if r := recover(); r != nil { log.Fatalf(\"s3.New: %v\", r) } }()","preventionTips":["Set AWS_REGION and credentials explicitly in deployment config","Run a startup health check that loads AWS config before building the pipeline","In containers, mount or bake readable ~/.aws files or rely on IAM roles"],"tags":["go","aws","s3","config","panic"],"backgroundTag":"missing-credentials","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}