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

  1. Read the wrapped err text to see which config source failed
  2. Unset/fix AWS_PROFILE, AWS_CONFIG_FILE, AWS_SHARED_CREDENTIALS_FILE in the server environment
  3. Confirm CloudflareR2.AccessKeyID and SecretAccessKey are present in config
  4. Upgrade/align the aws-sdk-go-v2 config module versions in go.mod to avoid known LoadDefaultConfig regressions
  5. 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

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


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/e49bb3d7ccaefe1c. Report an issue: GitHub.