flipped-aurora/gin-vue-admin · error

function bucketManager.Stat() failed, err:

Error message

function bucketManager.Stat() failed, err:

What it means

Wraps the error returned by the Qiniu SDK's bucketManager.Stat() call inside Exists(). Stat() queries the object's metadata; if it fails with anything other than a '612 no such file' response (which Exists treats as a clean false), the error is logged and re-wrapped with this prefix.

Source

Thrown at server/utils/upload/qiniu.go:89

// newBucketManager 创建七牛 BucketManager 实例。
func newBucketManager() *storage.BucketManager {
	mac := qbox.NewMac(global.GVA_CONFIG.Qiniu.AccessKey, global.GVA_CONFIG.Qiniu.SecretKey)
	cfg := qiniuConfig()
	return storage.NewBucketManager(mac, cfg)
}

// Exists 检查对象是否存在,七牛 code 612(或 "no such file")视为不存在。
func (*Qiniu) Exists(ctx context.Context, key string) (bool, error) {
	bucketManager := newBucketManager()
	if _, err := bucketManager.Stat(global.GVA_CONFIG.Qiniu.Bucket, key); err != nil {
		msg := err.Error()
		// 七牛 612 表示资源不存在
		if strings.Contains(msg, "612") || strings.Contains(msg, "no such file") || strings.Contains(msg, "no such file or directory") {
			return false, nil
		}
		logger.WithCtx(ctx).Mod("upload").Err(err).Error("function bucketManager.Stat() failed")
		return false, errors.New("function bucketManager.Stat() failed, err:" + err.Error())
	}
	return true, nil
}

// DeleteFiles 批量删除对象,通过通用 Batch 接口,逐项检查 code(200/204 成功)。
func (*Qiniu) DeleteFiles(ctx context.Context, keys []string) ([]DeleteFailure, error) {
	if len(keys) == 0 {
		return nil, nil
	}

	bucket := global.GVA_CONFIG.Qiniu.Bucket
	operations := make([]string, 0, len(keys))
	for _, key := range keys {
		operations = append(operations, storage.URIDelete(bucket, key))
	}

	bucketManager := newBucketManager()
	ret, err := bucketManager.Batch(operations)

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Verify GVA_CONFIG.Qiniu access-key/secret-key and bucket name in config.yaml
  2. Check the wrapped err text (suffix after 'err:') for the real Qiniu code (401 auth, 403 permission, network timeout)
  3. Confirm network access to the Qiniu zone endpoint for the configured bucket region
  4. If 612-style errors are expected, confirm the message-matching strings cover your SDK version's wording

Example fix

// before
ok, err := uploadQiniu.Exists(ctx, "missing-key") // returns wrapped Stat error on network/auth failure
// after
if err != nil && strings.Contains(err.Error(), "401") {
    // fix credentials in config.yaml before retrying
}
Defensive patterns

Strategy: try-catch

Validate before calling

// verify config before calling
if global.GVA_CONFIG.Qiniu.Bucket == "" || global.GVA_CONFIG.Qiniu.AccessKey == "" {
    return fmt.Errorf("qiniu config incomplete")
}

Try / catch

ok, err := q.Exists(ctx, key)
if err != nil {
    if strings.Contains(err.Error(), "401") || strings.Contains(err.Error(), "403") {
        // fix credentials
    } else {
        // transient: retry or degrade
    }
}

Prevention

When it happens

Trigger: Calling Exists(ctx, key) on Qiniu when bucketManager.Stat() returns a non-612 error: invalid credentials, missing bucket, network failure, or malformed key.

Common situations: Wrong AK/SK in config, bucket name typo in GVA_CONFIG.Qiniu.Bucket, network egress blocked to Qiniu region endpoint, or SDK returning 401/403/571 errors.

Related errors


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