Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Google Drive | 500 Unknown Error Yet File Still Created

Đang mở
#3,559 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
google-cloud, node.js, typescript
Lĩnh vực
api, cloud

Hướng nghiên cứu

Bắt đầu với entry point uploadFileToGoogleDrive được nêu trong issue và tái hiện lệnh gọi client.files.create bằng các phiên bản Node.js, googleapis và macOS được liệt kê. Kiểm tra hành vi của request và lỗi/response khi tệp được tạo mặc dù có 500; công việc được xem là hoàn tất khi lỗi gây hiểu nhầm được giải thích và kết quả upload mong đợi được xác định.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

priority: p2 type: bug

An 'Unknown Error' with code 500 keeps returning when using the Node SDK and google drive to upload a file.

I have tested that my OAuth client is working as I am able to retrieve file metadata from the drive. However, when I go to run the upload script below I get a 500 error, despite the file actually being created in Google Drive...

Environment details
  • OS: MacOS 14.5
  • Node.js version: v22.4.1
  • googleapis version: ^134.0.0
Steps to reproduce

Error Message

Google Drive API Error: {
  code: 500,
   message: 'Unknown Error.',
   errors: [ {} ],
  status: 'UNKNOWN'
}
export async function uploadFileToGoogleDrive(client: drive_v3.Drive, file: File, folderId?: string) {
    const upload = async () => {
        const response = await client.files.create({
            requestBody: {
                name: file.name,
                mimeType: file.type,
                ...(folderId ? { parents: [folderId] } : {})
            },
            media: {
                mimeType: file.type,
                body: Readable.from(file.stream()),
            },
            fields: 'id,name,mimeType,webViewLink,thumbnailLink',
        });
        console.log(response);
        return response;
    };

    try {
        // const response = await retry(upload, {
        //     retries: 2,
        //     factor: 2,
        //     minTimeout: 1000,
        //     maxTimeout: 60000,
        //     randomize: true,
        //     onFailedAttempt: error => {
        //         console.error(`Attempt ${error.attemptNumber} failed. There are ${error.retriesLeft} retries left.`);
        //     }
        // });
        const response = await upload()
        console.log('file uploaded', response)
        return response;
    } catch (err) {
        console.error('Error uploading file to Google Drive: ', err.stack);
        if (err.response && err.response.data && err.response.data.error) {
            console.error('Google Drive API Error:', err.response.data.error);
        }
        logger.error('Error uploading file to Google Drive', err);
        throw err;
    }
}
Ngôn ngữ chính
TypeScript
Star
12.3k
Fork
2k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
21

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của googleapis/google-api-nodejs-client

Tất cả issue của googleapis/google-api-nodejs-client

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.