Skip to content

Bug in convert_mimetype_of_file_on_google_drive: ReferenceError: blob is not defined #11

@zorrofox

Description

@zorrofox

Hello,

There appears to be a bug in the convert_mimetype_of_file_on_google_drive tool function.

Error:
When calling the tool with a valid file ID for a Google Slides presentation and dstMimeType: 'application/pdf', it fails with the following error:
ReferenceError: blob is not defined at management_drive.js:267:128

Code Analysis:
The issue seems to be in the management_drive.js file within the convert_mimetype_of_file_on_google_drive function.

The current implementation appears to be:

const file = DriveApp.getFileById(id);
const blob = file.getAs(dstMimeType);
const newFile = DriveApp.createFile(blob.setName(file.getName()));

Suggested Fix:
A more robust implementation, which should prevent this error, is to explicitly get the file's blob before converting its type. The line should be changed as follows:

From:

const blob = file.getAs(dstMimeType);

To:

const blob = file.getBlob().getAs(dstMimeType);

This change ensures a valid blob is retrieved before the conversion is attempted and should resolve the issue.

Thank you for maintaining this useful toolset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions