Skip to content

API should handle 404 errors correctly #500

@simplenotezy

Description

@simplenotezy

With the following code const campaigns = await customer.query( it fails with error:

Error: Parser cannot parse input: expected a value
    at Parser._processBuffer (/Users/me/Projects/project/backend/node_modules/.pnpm/stream-json@1.8.0/node_modules/stream-json/Parser.js:111:64)
    at Parser._transformBuffer (/Users/me/Projects/project/backend/node_modules/.pnpm/stream-json@1.8.0/node_modules/stream-json/utils/Utf8Stream.js:24:10)
    at Parser._transform (/Users/me/Projects/project/backend/node_modules/.pnpm/stream-json@1.8.0/node_modules/stream-json/utils/Utf8Stream.js:19:10)
    at Parser.Transform._write (node:internal/streams/transform:171:8)
    at writeOrBuffer (node:internal/streams/writable:564:12)
    at _write (node:internal/streams/writable:493:10)
    at Parser.Writable.write (node:internal/streams/writable:502:10)
    at IncomingMessage.ondata (node:internal/streams/readable:1007:22)
    at IncomingMessage.emit (node:events:518:28)
    at IncomingMessage.emit (node:domain:488:12) {stack: 'Error: Parser cannot parse input: expected a … at IncomingMessage.emit (node:domain:488:12)', message: 'Parser cannot parse input: expected a value'}

Full code example:

    const customer = client.Customer({
      customer_id: 'customers/XXX',
      refresh_token: credentials.key,
    });

    try {
      const campaigns = await customer.query(`
				SELECT 
					campaign.id, 
					campaign.name
				FROM 
					campaign
			`);
    } catch (error) {
      console.error(error);
    }

It appears to receive a 404 when issuing a request towards this URL:

https://googleads.googleapis.com/v16/customers/customers/XXX/googleAds:searchStream

When removing the customers/ prefix, the query works as intended.

Possible solutions:

  1. Properly handle 404 errors
  2. Automatically remove customers/ prefix from customer_id

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions