{"record":{"id":"f02653380ca140ce","repo":"Tencent/WeKnora","slug":"failed-to-upload-bytes-to-minio-w","errorCode":null,"errorMessage":"failed to upload bytes to MinIO: %w","messagePattern":"failed to upload bytes to MinIO: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/file/minio.go","lineNumber":218,"sourceCode":"}\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) {\n\tobjectName, err := s.parseMinioFilePath(filePath)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tpresignedURL, err := s.client.PresignedGetObject(ctx, s.bucketName, objectName, 24*time.Hour, nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to generate presigned URL: %w\", err)\n\t}\n\treturn presignedURL.String(), nil\n}\n","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/minio.go#L200-L236","documentation":"MinIO PutObject failed while uploading the in-memory byte payload to the generated exports object key, so the bytes were not persisted; bucket permissions, size limits, or connectivity are the usual wrapped causes.","triggerScenarios":"Thrown at internal/application/service/file/minio.go:218 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check MinIO health and write permissions","Verify quota/size limits for exports","Retry the byte upload on transient failures"],"exampleFix":null,"handlingStrategy":"retry","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"}