Tencent/WeKnora · error
bucket mismatch in path: got %s, want %s
Error message
bucket mismatch in path: got %s, want %s
What it means
S3 path parser guard: the bucket segment of the s3:// path does not equal the service's configured bucket name, indicating a path minted by a different backend/deployment; the operation is rejected to prevent cross-bucket access.
Source
Thrown at internal/application/service/file/s3.go:212
return err
}
return svc.CheckConnectivity(ctx)
}
// parseS3FilePath extracts the object name from a provider scheme: s3://{bucket}/{objectKey}
func (s *s3FileService) parseS3FilePath(filePath string) (string, error) {
// Provider scheme format: s3://{bucket}/{objectKey}
const prefix = "s3://"
if !strings.HasPrefix(filePath, prefix) {
return "", fmt.Errorf("invalid S3 file path: %s", filePath)
}
rest := strings.TrimPrefix(filePath, prefix)
parts := strings.SplitN(rest, "/", 2)
if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
return "", fmt.Errorf("invalid S3 file path: %s", filePath)
}
if parts[0] != s.bucketName {
return "", fmt.Errorf("bucket mismatch in path: got %s, want %s", parts[0], s.bucketName)
}
if err := utils.SafeObjectKey(parts[1]); err != nil {
return "", fmt.Errorf("invalid file path: %w", err)
}
return parts[1], nil
}
// SaveFile saves a file to S3
func (s *s3FileService) SaveFile(ctx context.Context,
file *multipart.FileHeader, tenantID uint64, knowledgeID string,
) (string, error) {
// Generate object name
ext := filepath.Ext(file.Filename)
objectName := fmt.Sprintf("%s%d/%s/%s%s", s.pathPrefix, tenantID, knowledgeID, uuid.New().String(), ext)
// Open file
src, err := file.Open()
if err != nil {View on GitHub (pinned to 988cbb0330)
Solutions
- Use paths previously returned by this S3 service
- Align the configured bucket name with the deployment
- Reject foreign-bucket paths at input validation
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/application/service/file/s3.go:212 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/d79fd94e6b5e783c.
Report an issue: GitHub.