{"record":{"id":"1edbbba69d5ebe6e","repo":"Tencent/WeKnora","slug":"invalid-file-name-w-1edbbb","errorCode":null,"errorMessage":"invalid file name: %w","messagePattern":"invalid file name: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/file/minio.go","lineNumber":207,"sourceCode":"\t_, err = s.client.CopyObject(ctx,\n\t\tminio.CopyDestOptions{Bucket: s.bucketName, Object: destKey},\n\t\tminio.CopySrcOptions{Bucket: s.bucketName, Object: srcKey},\n\t)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to copy file in MinIO: %w\", err)\n\t}\n\n\tnewPath := fmt.Sprintf(\"minio://%s/%s\", s.bucketName, destKey)\n\tlogger.Infof(ctx, \"Copied MinIO object %s to %s\", srcPath, newPath)\n\treturn newPath, nil\n}\n\n// SaveBytes saves bytes data to MinIO and returns the file path\n// temp parameter is ignored for MinIO (no auto-expiration support in this implementation)\nfunc (s *minioFileService) SaveBytes(ctx context.Context, data []byte, tenantID uint64, fileName string, temp bool) (string, error) {\n\tsafeName, err := utils.SafeFileName(fileName)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid file name: %w\", err)\n\t}\n\text := filepath.Ext(safeName)\n\tobjectName := fmt.Sprintf(\"%d/exports/%s%s\", tenantID, uuid.New().String(), ext)\n\n\t// Upload bytes to MinIO\n\treader := bytes.NewReader(data)\n\t_, err = s.client.PutObject(ctx, s.bucketName, objectName, reader, int64(len(data)), minio.PutObjectOptions{\n\t\tContentType: utils.GetContentTypeByExt(ext),\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to upload bytes to MinIO: %w\", err)\n\t}\n\n\treturn fmt.Sprintf(\"minio://%s/%s\", s.bucketName, objectName), nil\n}\n\n// GetFileURL returns a presigned download URL for the file\nfunc (s *minioFileService) GetFileURL(ctx context.Context, filePath string) (string, error) {","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/minio.go#L189-L225","documentation":"MinIO SaveBytes guard: the supplied file name was rejected by SafeFileName, meaning it contains unsafe characters or traversal-like constructs, so a sanitized export object key cannot be derived and the byte upload is refused.","triggerScenarios":"Thrown at internal/application/service/file/minio.go:207 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a plain file name without path separators or special characters","Sanitize file names where they originate","Whitelist extensions for export names"],"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"}