Tencent/WeKnora · error
invalid TOS file path: %s
Error message
invalid TOS file path: %s
What it means
TOS path parser guard: the path does not start with the 'tos://' scheme (or its bucket/key segments are empty after splitting), so no bucket/objectKey can be extracted and the operation is rejected before any storage call.
Source
Thrown at internal/application/service/file/tos.go:160
}
return fmt.Errorf("failed to check TOS bucket: %w", err)
}
func joinTOSObjectKey(parts ...string) string {
filtered := make([]string, 0, len(parts))
for _, part := range parts {
part = strings.Trim(part, "/")
if part != "" {
filtered = append(filtered, part)
}
}
return strings.Join(filtered, "/")
}
func parseTOSFilePath(filePath string) (bucketName string, objectKey string, err error) {
if !strings.HasPrefix(filePath, tosScheme) {
return "", "", fmt.Errorf("invalid TOS file path: %s", filePath)
}
rest := strings.TrimPrefix(filePath, tosScheme)
parts := strings.SplitN(rest, "/", 2)
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
return "", "", fmt.Errorf("invalid TOS file path: %s", filePath)
}
return parts[0], parts[1], nil
}
func (s *tosFileService) SaveFile(ctx context.Context, file *multipart.FileHeader, tenantID uint64, knowledgeID string) (string, error) {
ext := filepath.Ext(file.Filename)
objectName := joinTOSObjectKey(
s.pathPrefix,
fmt.Sprintf("%d", tenantID),
knowledgeID,
uuid.New().String()+ext,
)View on GitHub (pinned to 988cbb0330)
Solutions
- Pass paths in the form tos://{bucket}/{objectKey}
- Validate scheme and shape where the path originates
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/application/service/file/tos.go:160 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/486de44363ceb468.
Report an issue: GitHub.