Jira (PDB-5343) PQL dotted fields don't support double-quoted path components

4 views
Skip to first unread message

Reid Vandewiele (Jira)

unread,
Oct 25, 2021, 1:47:03 AM10/25/21
to puppe...@googlegroups.com
Reid Vandewiele created an issue
 
PuppetDB / Bug PDB-5343
PQL dotted fields don't support double-quoted path components
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/10/24 10:46 PM
Priority: Normal Normal
Reporter: Reid Vandewiele

PuppetDB documents its use of "dotted field[s], which represents a path into a JSON tree" here. Notably, "Any path component can be double-quoted" in order to accommodate specification of path components which themselves contain dot characters.

When writing PQL queries, however, such as the following, it is currently impossible to use this documented dotted field syntax.

inventory[certname, facts."my.fact.has.dots"] { LIMIT 1 }

The following error will be returned.

2021/10/25 05:37:14 ERROR - [GET /pdb/query/v4][400] getQueryBadRequest  PQL parse error at line 1, column 27:
 
inventory[certname, facts."my.fact.has.dots"] { }
                          ^
 
Expected one of:
 
#"match\(.*?\)"
#"[^\s\.\",\[\]!<=>~]+(\[\d+\])?"
#"\".*?\"(?=\.|\s)"

Expected outcome

The PQL given above should be equivalent to this AST query.

["from","inventory",["extract", ["certname", "facts.\"my.fact.has.dots\""]]]

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Reid Vandewiele (Jira)

unread,
Oct 25, 2021, 2:09:03 AM10/25/21
to puppe...@googlegroups.com
Reid Vandewiele updated an issue
Change By: Reid Vandewiele
PuppetDB documents its use of "dotted field[s], which represents a path into a JSON tree" [here|https://puppet.com/docs/puppetdb/7/api/query/v4/ast.html#dotted-field-syntax]. Notably, "Any path component can be double-quoted" in order to accommodate specification of path components which themselves contain dot characters.


When writing PQL queries, however, such as the following, it is currently impossible to use this documented dotted field syntax.

{code}
inventory[certname, facts."my.fact.has.dots"] { LIMIT 1
}
{code}

The following error will be returned.

{code}
2021/10/25 05:37:14 ERROR - [GET /pdb/query/v4][400] getQueryBadRequest  PQL parse error at line 1, column 27:

inventory[certname, facts."my.fact.has.dots"] { }
                     ^

Expected one of:

#"match\(.*?\)"
#"[^\s\.\",\[\]!<=>~]+(\[\d+\])?"
#"\".*?\"(?=\.|\s)"
{code}

h3. Expected outcome

The PQL given above *should* be equivalent to this AST query.

{code}
["from","inventory",["extract", ["certname", "facts.\"my.fact.has.dots\""]]]
{code}
Reply all
Reply to author
Forward
0 new messages