Skip to content

Commit 82acc05

Browse files
devin-ai-integration[bot]Convex, Inc.
authored and
Convex, Inc.
committed
fix: Improve JSON error handling in scenario-runner (#34451)
GitOrigin-RevId: 9425e42409b972f926761e7d55bf5e5e5aa130d0
1 parent 7e220c5 commit 82acc05

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

npm-packages/scenario-runner/index.ts

+24-9
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,31 @@ async function getProvisionerInfo(
6161
await fetch(`${deploymentUrl}/instance_name`)
6262
).text();
6363

64-
const info = await (
65-
await fetch(
66-
`${provisionHost}/api/deployment/${deploymentName}/team_and_project`,
67-
{
68-
headers: {
69-
Authorization: `Bearer ${accessToken}`,
70-
},
64+
const response = await fetch(
65+
`${provisionHost}/api/deployment/${deploymentName}/team_and_project`,
66+
{
67+
headers: {
68+
Authorization: `Bearer ${accessToken}`,
7169
},
72-
)
73-
).json();
70+
},
71+
);
72+
73+
if (!response.ok) {
74+
const responseText = await response.text();
75+
throw new Error(
76+
`HTTP error ${response.status}: ${response.statusText}. Response: ${responseText}`,
77+
);
78+
}
79+
80+
let info;
81+
try {
82+
info = await response.json();
83+
} catch (e: unknown) {
84+
const responseText = await response.text();
85+
throw new Error(
86+
`Failed to parse JSON response: ${e instanceof Error ? e.message : String(e)}. Full response: ${responseText}`,
87+
);
88+
}
7489
const deploymentId = info.deploymentId;
7590

7691
return {

0 commit comments

Comments
 (0)