A GLQL panel can be written three ways: a YAML block with a query: key, frontmatter plus a query, or a bare query. The GLQL parser and the GLQL API already accept all three. Analyze with Duo did not. withFilters parsed the panel as a single YAML document and required a query key, so the other two forms threw, were reported to Sentry, and never reached the agent.
There was a second crash in the same area. A map without a query key was treated as config, and parseQuery threw TypeError. Users got a frontend exception instead of a compiler syntax error.
This is the story of gitlab-org/gitlab!270787, a parse path that follows the API, and a review that kept correcting my examples until they were real GLQL.
The issue: two failures, one root
The issue was gitlab-org/gitlab#639779, opened by Miguel Rincon. The title is the whole bug: the GLQL frontend failed on blocks the GLQL API already accepted. Analyze with Duo dropped panels, and a map without query crashed.
The shape of the fix had already been agreed in an earlier MR: read the panel with the same parse path withDimension uses, and leave unscoped panels out so the agent never gets a query that has no dashboard scope.
The first version only fixed Duo
The first commit taught withFilters to read a query: block with yaml.parse, and to read frontmatter and bare queries with parseQueryTextWithFrontmatter. Invalid frontmatter was still left out and reported to Sentry. Dashboard filters were written back as a query: block.
Rudy approved that approach, then blocked on the second half of the issue. A map without query (title: x, in the early examples) still crashed the shared parser. Either the commit should say Related to instead of Closes, or the parseYAML fix belonged in the same MR. I added the parser fix.
parseYAML now uses the whole text as the query when the block is not a map with a string query key, matching ParserService#get_standard_yaml. The compiler can report a syntax error instead of throwing TypeError.
export const parseMap = (text) => { try { const parsed = parseYaml(text, YAML_OPTIONS); return isPlainObject(parsed) ? parsed : null; } catch { return null; } }; export const parseYAML = (yaml) => { let { frontmatter: config, query } = parseQueryTextWithFrontmatter(yaml); const block = config ? null : parseMap(yaml); if (typeof block?.query === 'string') { ({ query, ...config } = block); config.display = config.display || DEFAULT_DISPLAY_TYPE; } else { config = parseYAMLConfig(config); } // ... }; withFilters reuses parseMap. A query: document goes through apply. Anything else is split as frontmatter, or treated as a bare query:
const block = parseMap(glql); if (typeof block?.query === 'string') return apply(block); const { frontmatter, query } = parseQueryTextWithFrontmatter(glql); const config = frontmatter ? parseMap(frontmatter) : {}; if (frontmatter && !config) { throw new Error('GLQL panel frontmatter must be YAML key-value pairs'); } return apply({ ...config, query }); apply trims the query before appending dashboard clauses. A whitespace-only query is dropped, so you do not end up with ' and group = "..."'.
The review that fixed the examples
Robert asked to keep the "panel that cannot be scoped" example. That path is still live: frontmatter that is not valid YAML is left out, and Sentry gets the error with the panel title. The describe.each that used to cover it had been removed. It went back in.
Daniele Rossetti mentioned a series of subtler problems, and the examples I had written were some of them.
Non-map frontmatter was being spread into the agent context. ---\nanalytics\n---\ntype = DuoWorkflow became '0': a, '1': 'n', and so on. ParserService already refuses frontmatter that is not key-value pairs. The new if (frontmatter && !config) throw drops that panel the same way invalid frontmatter is dropped, instead of inventing a broken context object.
The first specs were not valid GLQL. title: x is not a query. ~ is not a GLQL operator, and title is not a work item filter. The reason we parse a map without a query key as a query at all is queries that YAML happens to read as a map, like type = Issue and label = "priority: high". A real query that makes yaml.parse throw is type = Issue and label = "priority: high" and milestone = "Sprint: 1". The specs now use those two. Daniele was careful to say the earlier examples were his too, and to replace them.
parseMap has to catch, not only reject a non-map. A bare query with colons can make yaml.parse throw. Returning null in that case is what lets the frontmatter split, or the raw text, take over. Without the catch, you are back to a frontend exception.
The MR has Changelog: fixed and EE: true, because Analyze with Duo is EE-only, even though parser.js is in the shared GLQL code.
What I took away
1. If the API already accepts three forms, a client that accepts one is a bug, not a taste difference. Analyze with Duo was dropping panels that the compiler would have run.
2. Closing the issue means fixing both halves. The first commit was a Duo-only fix. The TypeError in parseYAML was the other half of #639779. Related to would have been honest. Putting the parser fix in the same MR was better.
3. Do not invent GLQL in a spec. A string that only looks like a query will not compile, and it will not exercise the YAML path you care about. Use a query YAML reads as a map, and one that makes YAML throw.
4. Spreading a non-map is a good way to ship garbage to the agent. If the service already requires key-value pairs, throw at the same point and drop the panel.
5. Trim before you concatenate filters. A blank query: with dashboard clauses attached is a new, worse query, not a no-op.
The MR merged on 19 November 2026.
Links
- Issue: gitlab-org/gitlab#639779
- Merge request: gitlab-org/gitlab!270787
Thanks to Miguel Rincon for the issue, to Rudy Crespo for insisting the shared parser was in scope and for putting the unscoped-panel example back, and to Daniele Rossetti for the frontmatter, trim, and real-GLQL review.
If you've been thinking about contributing to GitLab, the community issues are a great place to start: contributors.gitlab.com.
