Skip to content

Commit cbbfc7b

Browse files
committed
Adding JSON parse error handling
1 parent cccb629 commit cbbfc7b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

components/google_drive/common/utils.mjs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import fs from "fs";
2-
import { axios } from "@pipedream/platform";
2+
import {
3+
axios, ConfigurationError,
4+
} from "@pipedream/platform";
35
import {
46
MY_DRIVE_VALUE,
57
LEGACY_MY_DRIVE_VALUE,
@@ -266,9 +268,16 @@ function optionalParseAsJSON(value) {
266268
}
267269

268270
function parseObjectEntries(value = {}) {
269-
const obj = typeof value === "string"
270-
? JSON.parse(value)
271-
: value;
271+
let obj;
272+
if (typeof value === "string") {
273+
try {
274+
obj = JSON.parse(value);
275+
} catch (e) {
276+
throw new ConfigurationError(`Invalid JSON string provided: ${e.message}`);
277+
}
278+
} else {
279+
obj = value;
280+
}
272281
return Object.fromEntries(
273282
Object.entries(obj).map(([
274283
key,

0 commit comments

Comments
 (0)