flipped-aurora/gin-vue-admin · error
function bucketManager.ListFiles() failed, err:
Error message
function bucketManager.ListFiles() failed, err:
What it means
Wraps an error from Qiniu's bucketManager.ListFiles() in ListFiles(). ListFiles enumerates bucket objects with prefix/marker pagination; any SDK-level failure (auth, network, bad cursor) produces this error.
Source
Thrown at server/utils/upload/qiniu.go:141
key = keys[i]
}
failed = append(failed, DeleteFailure{Key: key, Err: fmt.Errorf("delete failed, code: %d", op.Code)})
}
}
return failed, nil
}
// ListFiles 按前缀列举对象,cursor 映射为七牛的 marker。
func (*Qiniu) ListFiles(ctx context.Context, prefix, cursor string, limit int) ([]FileInfo, string, bool, error) {
if limit <= 0 {
limit = 100
}
bucketManager := newBucketManager()
entries, _, nextMarker, hasNext, err := bucketManager.ListFiles(global.GVA_CONFIG.Qiniu.Bucket, prefix, "", cursor, limit)
if err != nil {
logger.WithCtx(ctx).Mod("upload").Err(err).Error("function bucketManager.ListFiles() failed")
return nil, "", false, errors.New("function bucketManager.ListFiles() failed, err:" + err.Error())
}
files := make([]FileInfo, 0, len(entries))
for _, entry := range entries {
// PutTime 单位为 100 纳秒,除以 1e7 得到秒级 Unix 时间戳
files = append(files, FileInfo{
Key: entry.Key,
Size: entry.Fsize,
LastModified: time.Unix(0, entry.PutTime*100),
ContentType: entry.MimeType,
})
}
nextCursor := ""
if hasNext {
nextCursor = nextMarker
}
return files, nextCursor, hasNext, nilView on GitHub (pinned to 3136500ef3)
Solutions
- Check the wrapped err suffix for the real Qiniu error (401/403/network)
- Verify bucket name and credentials in GVA_CONFIG.Qiniu
- Restart listing from an empty cursor if a stale marker is rejected
- Confirm network connectivity to the bucket's region endpoint
Example fix
// before
files, marker, hasMore, err := q.ListFiles(ctx, "", staleMarker, 10)
// after
if err != nil && strings.Contains(err.Error(), "marker") {
files, marker, hasMore, err = q.ListFiles(ctx, "", "", 10) // restart pagination
} Defensive patterns
Strategy: try-catch
Validate before calling
if cursor != "" && !isValidMarker(cursor) {
cursor = "" // restart from beginning
} Try / catch
files, marker, hasMore, err := q.ListFiles(ctx, prefix, cursor, limit)
if err != nil {
// inspect wrapped error; reset cursor and retry once
return nil, "", false, fmt.Errorf("list objects failed: %w", err)
} Prevention
- Always feed back the exact nextMarker returned by the previous page
- Validate bucket/credentials at startup
- Handle pagination restarts for stale markers
When it happens
Trigger: Calling ListFiles(ctx, prefix, cursor, limit) when the Qiniu list API fails: invalid marker/cursor from a stale page, auth error, or network failure.
Common situations: Passing an expired or malformed nextMarker as cursor, wrong bucket config, region endpoint unreachable, SDK credentials revoked.
Related errors
- function formUploader.Put() failed, err:
- function bucketManager.Stat() failed, err:
- function bucketManager.Batch() failed, err:
- 上传文件到minio失败, err:
- function file.Open() failed, err:
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/21067b0869a6ed61.
Report an issue: GitHub.