Skip to content

Commit 2c64fe8

Browse files
[BUG] Special characters are potentially breaking the searchName prop for Google Drive Actions (#16897)
Co-authored-by: Danny Roosevelt <danny@pipedream.com>
1 parent 56a1a2e commit 2c64fe8

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

components/google_drive/actions/find-folder/find-folder.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "google_drive-find-folder",
88
name: "Find Folder",
99
description: "Search for a specific folder by name. [See the documentation](https://developers.google.com/drive/api/v3/search-files) for more information",
10-
version: "0.1.8",
10+
version: "0.1.9",
1111
type: "action",
1212
props: {
1313
googleDrive,
@@ -34,16 +34,24 @@ export default {
3434
},
3535
},
3636
async run({ $ }) {
37-
let q = `mimeType = '${GOOGLE_DRIVE_FOLDER_MIME_TYPE}' and name contains '${this.nameSearchTerm}'`.trim();
37+
const escapedSearchTerm = this.nameSearchTerm?.replace(/'/g, "\\'") || "";
38+
let q = `mimeType = '${GOOGLE_DRIVE_FOLDER_MIME_TYPE}' and name contains '${escapedSearchTerm}'`.trim();
3839
if (!this.includeTrashed) {
3940
q += " and trashed=false";
4041
}
4142
const opts = getListFilesOpts(this.drive, {
4243
q,
4344
});
44-
const folders = (await this.googleDrive.listFilesInPage(null, opts)).files;
45-
// eslint-disable-next-line multiline-ternary
46-
$.export("$summary", `Successfully found ${folders.length} folder${folders.length === 1 ? "" : "s"} containing the term, "${this.nameSearchTerm}"`);
47-
return folders;
45+
46+
try {
47+
const { files: folders } = await this.googleDrive.listFilesInPage(null, opts);
48+
// eslint-disable-next-line multiline-ternary
49+
$.export("$summary", `Successfully found ${folders.length} folder${folders.length === 1 ? "" : "s"} containing the term, "${this.nameSearchTerm}"`);
50+
return folders;
51+
52+
} catch (error) {
53+
console.log("Failed to find folders with query", error.response?.data?.error || error);
54+
throw JSON.stringify(error.response?.data?.error, null, 2);
55+
}
4856
},
4957
};

components/google_drive/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/google_drive",
3-
"version": "0.9.1",
3+
"version": "0.9.2",
44
"description": "Pipedream Google_drive Components",
55
"main": "google_drive.app.mjs",
66
"keywords": [

pnpm-lock.yaml

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)