{"record":{"id":"7fc446cb72e9e8fa","repo":"Tencent/WeKnora","slug":"invalid-s3-file-path-s","errorCode":null,"errorMessage":"invalid S3 file path: %s","messagePattern":"invalid S3 file path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/file/s3.go","lineNumber":204,"sourceCode":"// It creates a temporary service instance internally and delegates to CheckConnectivity.\nfunc CheckS3Connectivity(ctx context.Context, endpoint, accessKey, secretKey, bucketName, region string) error {\n\treturn CheckS3ConnectivityWithOptions(ctx, endpoint, accessKey, secretKey, bucketName, region, false)\n}\n\nfunc CheckS3ConnectivityWithOptions(ctx context.Context, endpoint, accessKey, secretKey, bucketName, region string, forcePathStyle bool) error {\n\tsvc, err := newS3Client(endpoint, accessKey, secretKey, bucketName, region, \"\", forcePathStyle)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn svc.CheckConnectivity(ctx)\n}\n\n// parseS3FilePath extracts the object name from a provider scheme: s3://{bucket}/{objectKey}\nfunc (s *s3FileService) parseS3FilePath(filePath string) (string, error) {\n\t// Provider scheme format: s3://{bucket}/{objectKey}\n\tconst prefix = \"s3://\"\n\tif !strings.HasPrefix(filePath, prefix) {\n\t\treturn \"\", fmt.Errorf(\"invalid S3 file path: %s\", filePath)\n\t}\n\trest := strings.TrimPrefix(filePath, prefix)\n\tparts := strings.SplitN(rest, \"/\", 2)\n\tif len(parts) != 2 || parts[0] == \"\" || parts[1] == \"\" {\n\t\treturn \"\", fmt.Errorf(\"invalid S3 file path: %s\", filePath)\n\t}\n\tif parts[0] != s.bucketName {\n\t\treturn \"\", fmt.Errorf(\"bucket mismatch in path: got %s, want %s\", parts[0], s.bucketName)\n\t}\n\tif err := utils.SafeObjectKey(parts[1]); err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid file path: %w\", err)\n\t}\n\treturn parts[1], nil\n}\n\n// SaveFile saves a file to S3\nfunc (s *s3FileService) SaveFile(ctx context.Context,\n\tfile *multipart.FileHeader, tenantID uint64, knowledgeID string,","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/s3.go#L186-L222","documentation":"Path-format validation in parseS3FilePath: the supplied file path does not match the expected s3:// scheme/shape (missing or empty bucket or object-key component), so it cannot be decomposed for storage operations. Raised by GetFile, DeleteFile, CopyFile, GetFileURL whenever they receive a non-s3 or malformed path.","triggerScenarios":"Thrown at internal/application/service/file/s3.go:204 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass paths in the form s3://{bucket}/{objectKey}","Validate the scheme where the path was produced"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}