{"record":{"id":"ff43b3b936c23ef2","repo":"Tencent/WeKnora","slug":"failed-to-open-file-w-ff43b3","errorCode":null,"errorMessage":"failed to open file: %w","messagePattern":"failed to open file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/file/minio.go","lineNumber":133,"sourceCode":"\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 MinIO\nfunc (s *minioFileService) SaveFile(ctx context.Context,\n\tfile *multipart.FileHeader, tenantID uint64, knowledgeID string,\n) (string, error) {\n\t// Generate object name\n\text := filepath.Ext(file.Filename)\n\tobjectName := fmt.Sprintf(\"%d/%s/%s%s\", tenantID, knowledgeID, uuid.New().String(), ext)\n\n\t// Open file\n\tsrc, err := file.Open()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to open file: %w\", err)\n\t}\n\tdefer src.Close()\n\n\t// Upload file to MinIO\n\t_, err = s.client.PutObject(ctx, s.bucketName, objectName, src, file.Size, minio.PutObjectOptions{\n\t\tContentType: file.Header.Get(\"Content-Type\"),\n\t})\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to upload file to MinIO: %w\", err)\n\t}\n\n\treturn fmt.Sprintf(\"minio://%s/%s\", s.bucketName, objectName), nil\n}\n\n// GetFile gets a file from MinIO\nfunc (s *minioFileService) GetFile(ctx context.Context, filePath string) (io.ReadCloser, error) {\n\tobjectName, err := s.parseMinioFilePath(filePath)\n\tif err != nil {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/minio.go#L115-L151","documentation":"Opening the uploaded multipart file header failed before the MinIO upload could begin: the underlying file descriptor could not be opened (already consumed, deleted temp file, or I/O error), so nothing is uploaded.","triggerScenarios":"Thrown at internal/application/service/file/minio.go:133 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the upload request","Ensure the multipart file is not read twice without re-opening","Check server temp storage health"],"exampleFix":null,"handlingStrategy":"try-catch","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"}