Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

parseHttpRespBody could provide a more helpful error message when the response can't be parsed as JSON #446

@Tyler-Murphy

Description

@Tyler-Murphy

Is your feature request related to a problem? Please describe.

I see the following error message in my code very occasionally. I think it's coming from here.

 Error: Cannot parse JSON response                                                                                                                                                                                                            +
     at Util.parseHttpRespBody (/app/node_modules/@google-cloud/common/build/src/util.js:186:42)                                                                                                                                              +
     at Util.handleResp (/app/node_modules/@google-cloud/common/build/src/util.js:135:117)                                                                                                                                                    +
     at /app/node_modules/@google-cloud/common/build/src/util.js:242:26                                                                                                                                                                       +
     at /app/node_modules/teeny-request/build/src/index.js:156:17                                                                                                                                                                             +
     at processTicksAndRejections (internal/process/task_queues.js:85:5)

Describe the solution you'd like

I'd like the response that couldn't be JSON-parsed to be surfaced, either in the error message, or in logs. I think I'd prefer to see it in the error message. It'd make troubleshooting easier, and it would allow me to write error-dependent retries.

I know that Google APIs sometimes return generic HTML errors, but it's hard to tell if that's what's happening here.

If it sounds okay to add the error message, I'd be happy to make a PR. Let me know!

Metadata

Metadata

Labels

🚨This issue needs some love.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions