flipped-aurora/gin-vue-admin · error
function config.LoadDefaultConfig() failed, err:
Error message
function config.LoadDefaultConfig() failed, err:
What it means
newR2Client constructs an aws.Config via config.LoadDefaultConfig using the statically provided Cloudflare R2 credentials; an SDK error there is wrapped in this message. Called lazily by every public R2 operation, so any upload/delete/list/exists call can surface it. The failure is in building the AWS config, not in talking to R2.
Source
Thrown at server/utils/upload/cloudflare_r2.go:212
hasMore = *out.IsTruncated
}
return files, nextCursor, hasMore, nil
}
func (*CloudflareR2) newR2Client() (*s3.Client, error) {
endpoint := fmt.Sprintf("https://%s.r2.cloudflarestorage.com", global.GVA_CONFIG.CloudflareR2.AccountID)
cfg, err := config.LoadDefaultConfig(context.TODO(),
config.WithRegion("auto"),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(
global.GVA_CONFIG.CloudflareR2.AccessKeyID,
global.GVA_CONFIG.CloudflareR2.SecretAccessKey,
"",
)),
)
if err != nil {
logger.Bg().Mod("upload").Err(err).Error("function config.LoadDefaultConfig() failed")
return nil, errors.New("function config.LoadDefaultConfig() failed, err:" + err.Error())
}
return s3.NewFromConfig(cfg, func(o *s3.Options) {
o.BaseEndpoint = aws.String(endpoint)
}), nil
}
View on GitHub (pinned to 3136500ef3)
Solutions
- Read the wrapped err text to see which config source failed
- Unset/fix AWS_PROFILE, AWS_CONFIG_FILE, AWS_SHARED_CREDENTIALS_FILE in the server environment
- Confirm CloudflareR2.AccessKeyID and SecretAccessKey are present in config
- Upgrade/align the aws-sdk-go-v2 config module versions in go.mod to avoid known LoadDefaultConfig regressions
- Reproduce with a minimal LoadDefaultConfig call in a test using testutil config loading
Example fix
// before (deployment yaml)
env:
- name: AWS_PROFILE
value: default
// after
env: [] # let static credentials from GVA_CONFIG be used Defensive patterns
Strategy: validation
Validate before calling
if cfg.CloudflareR2.AccessKeyID == "" || cfg.CloudflareR2.SecretAccessKey == "" {
return errors.New("CloudflareR2 credentials missing")
}
if os.Getenv("AWS_PROFILE") != "" {
return errors.New("AWS_PROFILE would override static R2 credentials")
} Type guard
null
Try / catch
client, err := newR2Client(endpoint)
if err != nil {
logger.Error("R2 client init failed", zap.Error(err))
return fmt.Errorf("r2 client init: %w", err)
} Prevention
- Sanitize the deployment environment of stray AWS_* env vars
- Fail fast at startup by eagerly constructing the R2 client
- Keep aws-sdk-go-v2 versions consistent and updated in go.mod
- Store R2 keys in config/secrets manager, never the shared-credentials file
When it happens
Trigger: Any public method on CloudflareR2 when LoadDefaultConfig fails — typically because shared-config/profile resolution (AWS_PROFILE, AWS_CONFIG_FILE) or region resolution errors, overriding the static credentials.
Common situations: Container images with AWS_PROFILE set to a nonexistent profile, corrupt shared credentials file mounted into the pod, SDK env var interference, or an SDK version change altering default config-file loading behavior.
Related errors
- function config.LoadDefaultConfig() failed, err:
- 未找到 MCP 独立配置文件,请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG
- 未能自动识别项目根目录,请在 MCP 配置中设置 autocode.root
- go.mod 中未找到 module 定义
- autocode根路径未配置
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/e49bb3d7ccaefe1c.
Report an issue: GitHub.