New Relic NRQL syntax error in CI
New Relic returns an "NRQL Syntax Error" when a query run via NerdGraph or the CLI is malformed: a missing FROM, an unknown function, or a stray token. The response names the position it could not parse.
What this error means
A NerdGraph nrql query or a CLI deployment/SLI check returns "NRQL Syntax Error" with the offending position, and the step fails.
NRQL Syntax Error: Error at line 1 position 28, unexpected 'WERE'
SELECT count(*) FROM Transaction WERE appName = 'web'Common causes
A typo or missing clause in the NRQL
A misspelled keyword (WERE for WHERE), a missing FROM, or an unclosed string makes the query unparseable.
Unescaped interpolation in the CI step
A shell or YAML variable injected into the query without proper quoting produces invalid NRQL at runtime.
How to fix it
Fix the NRQL at the reported position
- Read the line and position in the syntax error.
- Correct the keyword, clause, or quoting at that spot.
- Re-run the query to confirm it parses.
newrelic nerdgraph query \
"{ actor { account(id: $ACCT) { nrql(query: \"SELECT count(*) FROM Transaction WHERE appName = 'web'\") { results } } } }"Quote interpolated values safely
Wrap injected values in proper quotes so the assembled NRQL stays valid regardless of the value.
How to prevent it
- Validate NRQL queries before wiring them into CI gates.
- Quote interpolated variables so the query stays well-formed.
- Keep complex queries in files rather than inline shell strings.