Tencent/WeKnora · error
object key cannot be empty
Error message
object key cannot be empty
What it means
Input guard in SafeObjectKey (security.go): an empty object-storage key was supplied for a COS/MinIO/S3 operation. GetFile, DeleteFile, CopyFile, GetFileURL, and path parsers all funnel through this check, which also rejects keys containing traversal sequences.
Source
Thrown at internal/utils/security.go:150
return "", fmt.Errorf("fileName cannot be empty")
}
base := filepath.Base(filepath.Clean(fileName))
if base == "" || base == "." || base == ".." {
return "", fmt.Errorf("invalid fileName: path traversal or empty name")
}
if strings.Contains(base, "..") {
return "", fmt.Errorf("invalid fileName: contains path traversal")
}
if len(base) > 255 {
return "", fmt.Errorf("fileName too long")
}
return base, nil
}
// SafeObjectKey 校验对象存储的 key(如 COS/MinIO objectName),禁止包含 ".." 等路径遍历
func SafeObjectKey(objectKey string) error {
if objectKey == "" {
return fmt.Errorf("object key cannot be empty")
}
if strings.Contains(objectKey, "..") {
return fmt.Errorf("object key contains path traversal")
}
return nil
}
// IsValidURL 验证 URL 是否安全
func IsValidURL(url string) bool {
if url == "" {
return false
}
// 检查长度
if len(url) > 2048 {
return false
}
View on GitHub (pinned to 988cbb0330)
Solutions
- Supply a non-empty object key built from validated components
- Check the upstream record/store for why the key is empty
- Never forward empty keys to the object-storage client
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/utils/security.go:150 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/45acc8c69ba3accf.
Report an issue: GitHub.