flipped-aurora/gin-vue-admin · error
function bucket.IsObjectExist() failed, err:
Error message
function bucket.IsObjectExist() failed, err:
What it means
Returned by AliyunOSS.Exists (server/utils/upload/aliyun_oss.go:89) when bucket.IsObjectExist(key) fails. IsObjectExist issues a HeadObject request against the OSS bucket via the aliyun-oss-go-sdk; any transport error, authentication failure, permission denial, or bucket mismatch is wrapped here. Note that a nonexistent object is NOT an error — it returns (false, nil); this error means the check itself could not be performed.
Source
Thrown at server/utils/upload/aliyun_oss.go:89
if err != nil {
return nil, err
}
return bucket, nil
}
// Exists 检查对象是否存在,"不存在"统一降级为 (false, nil)。
func (*AliyunOSS) Exists(ctx context.Context, key string) (bool, error) {
bucket, err := NewBucket()
if err != nil {
logger.WithCtx(ctx).Mod("upload").Err(err).Error("function AliyunOSS.NewBucket() Failed")
return false, errors.New("function AliyunOSS.NewBucket() Failed, err:" + err.Error())
}
exist, err := bucket.IsObjectExist(key)
if err != nil {
logger.WithCtx(ctx).Mod("upload").Err(err).Error("function bucket.IsObjectExist() failed")
return false, errors.New("function bucket.IsObjectExist() failed, err:" + err.Error())
}
return exist, nil
}
// DeleteFiles 批量删除对象,对比入参与已删除列表,未删的收集为 DeleteFailure。
func (*AliyunOSS) DeleteFiles(ctx context.Context, keys []string) ([]DeleteFailure, error) {
if len(keys) == 0 {
return nil, nil
}
bucket, err := NewBucket()
if err != nil {
logger.WithCtx(ctx).Mod("upload").Err(err).Error("function AliyunOSS.NewBucket() Failed")
return nil, errors.New("function AliyunOSS.NewBucket() Failed, err:" + err.Error())
}
result, err := bucket.DeleteObjects(keys)
if err != nil {View on GitHub (pinned to 3136500ef3)
Solutions
- Verify config.AliyunOSS: Endpoint (e.g. oss-cn-hangzhou.aliyuncs.com), AccessKeyId/Secret, BucketName all correct and the bucket exists in that region
- Test credentials with `ossutil ls` or a minimal oss.New + bucket.IsObjectExist snippet to see the raw OSS error code
- Check RAM permissions: grant the user oss:GetObject on the bucket/resource arn
- Check network reachability/DNS to the endpoint from the server (curl the endpoint URL)
- Inspect the wrapped err text — OSS SDK errors carry ServiceError codes like SignatureDoesNotMatch or AccessDenied that pinpoint the cause
Example fix
// before
exist, err := bucket.IsObjectExist(key)
if err != nil {
return false, errors.New("function bucket.IsObjectExist() failed, err:" + err.Error())
}
// after: distinguish auth/config failure from transient network issues
exist, err := bucket.IsObjectExist(key)
if err != nil {
var serr oss.ServiceError
if errors.As(err, &serr) && serr.StatusCode == 403 {
logger.WithCtx(ctx).Mod("upload").Error("OSS AccessDenied: check AK/permissions")
}
return false, fmt.Errorf("function bucket.IsObjectExist() failed: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
cfg := global.GVA_CONFIG.AliyunOSS
if cfg.Endpoint == "" || cfg.AccessKeyId == "" || cfg.BucketName == "" {
return errors.New("aliyun-oss config incomplete")
} Type guard
func isOSSServiceError(err error) (oss.ServiceError, bool) {
var se oss.ServiceError
if errors.As(err, &se) {
return se, true
}
return oss.ServiceError{}, false
} Try / catch
exist, err := uploadSvc.Exists(ctx, key)
if err != nil {
if se, ok := isOSSServiceError(err); ok {
logger.Errorf("OSS check failed code=%s status=%d", se.Code, se.StatusCode)
}
// decide: treat as 'unknown' and skip, or abort the operation
return fmt.Errorf("object existence check unavailable: %w", err)
} Prevention
- Validate the AliyunOSS config block at application startup with a real NewBucket round-trip
- Grant the RAM user explicit oss:GetObject/oss:ListObjects read permissions
- Pin the endpoint to the bucket's actual region; never mix regions
- Log the raw wrapped OSS error code (ServiceError.Code) to distinguish auth vs network vs permission
When it happens
Trigger: Calling Exists with an invalid/expired AccessKeyId or AccessKeySecret, wrong Endpoint (region mismatch or non-standard endpoint format), a BucketName that doesn't exist or belongs to another account, network/DNS failure reaching the endpoint, or missing oss:GetObject/HeadObject permission (AccessDenied 403).
Common situations: Misconfigured config.AliyunOSS values (typo in endpoint like missing https:// or wrong region), RAM user lacking read permission on the bucket, key rotated or revoked in Aliyun console, bucket deleted/renamed, offline or restricted-network deployment (e.g. container without egress to oss-*.aliyuncs.com).
Related errors
- function bucket.DeleteObjects() failed, err:
- 对象未被删除
- function client.ListObjectsV2() failed, err:
- 构建请求失败: %w
- LLM stream request timed out
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/46103b67f29e8139.
Report an issue: GitHub.