PipedreamHQ / PipedreamHQ/pipedream

google_ads: query builder produces invalid GAQL for some fields and search terms

Open
#21,961 0 comments 0 reactions 1 assignee Claimed by @Priyadharshan-Pdm View on GitHub
action bug triaged
Dominant language
JavaScript
Stars
11.7k
Forks
5.8k
Avg merge
3d 10h
Merged PRs (30d)
102

Description

## Problem

1. `checkPrefix` in `common/utils.mjs` checks whether a field name starts with the resource name, rather than the resource name followed by a dot. Fields whose own name begins with the resource name are left unprefixed. On a campaign report, `campaign_budget` and `campaign_group` produce `SELECT campaign_budget FROM campaign`, which the API rejects. `customer_agreement_setting.*` has the same problem on the customer resource.

This is easy to hit because the dropdown label shows the unprefixed name while the stored value is prefixed. Passing the name shown on screen is enough to break the query, and agents reading labels are especially likely to do it.

2. `sanitizeGaqlString` escapes single quotes only. GAQL requires `[`, `]`, `%` and `_` to be bracket-escaped when used with `LIKE`. Every search-as-you-type dropdown builds `LIKE '%%'`, so a search containing one of those characters can produce an invalid query. The Managed Account picker labels manager accounts as `[Manager] ...`, so searching for the text shown in the list is a plausible way to trigger it.

3. Both cases return a 400, and rejected requests still count against the daily quota.

## What's needed

- Field prefixing that matches the full prefix rather than a partial string.
- Search text escaped for the `LIKE` operator before it goes into a query.

## Notes

- GAQL grammar and `LIKE` escaping rules: https://developers.google.com/google-ads/api/docs/query/grammar
- Failed requests that return a Google Ads failure still count against the daily quota: https://developers.google.com/google-ads/api/docs/best-practices/quotas
- Context: quota exhaustion reported in #19945, #21509, #21554, #21782, #21926.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.