Bug #10915
closedNo clear error message when calling api with curl and data are not url-encoded
Description
Hi,
It seems that there is a problem when parsing parameters in curl requests :
curl -s -k -X GET -H "X-API-Token:mytoken" 'https://rudder-server/rudder/api/latest/nodes?where=\[\{"objectType":"serializedNodeProperty","attribute":"name.value","comparator":"regex","value":"ref=vm2345"\}\]'
{"action":"listAcceptedNodes","result":"error","errorDetails":"error with query"}
'ref=vm' is parsed as a query parameter by the web framework and break the query.
With %3D in place of = it works :
curl -s -k -X GET -H "X-API-Token:mytoken" 'https://rudder-server/rudder/api/latest/nodes?where=\[\{"objectType":"serializedNodeProperty","attribute":"name.value","comparator":"regex","value":"ref%3Dvm2345"\}\]'
{
"action": "listAcceptedNodes",
"result": "success",
"data": {
"nodes": [
{
"id": "5573be84-d36e-4d98-b72f-17abe3963d33",
"hostname": "rudder-agent1.novalocal",
"status": "accepted",
"os": {
"type": "Linux",
"name": "Debian",
"version": "8.8",
"fullName": "Debian GNU/Linux 8.8 (jessie)",
"kernelVersion": "3.16.0-4-amd64"
},
"architectureDescription": "x86_64-linux-thread-multi",
"ram": 2010,
"machine": {
"id": "f9660688-95dd-8bc5-eca8-52fa68acff88",
....
Updated by Benoît PECCATTE over 7 years ago
I'm afraid won't be able to change this.
Before the '?' is the request part, after it and before '#' are the parameter part.
Even if not requested by rfc, almost all http software then split the parameters with '&' and key/values with '='.
Any character you want in those parts that one of the aforementioned (and some others) must be first urlencoded (ie with %xx).
Hopefully there exist many tools to do this.
curl can even do it for you with the option --data-urlencode
Updated by François ARMAND over 7 years ago
- Subject changed from Problem when calling api with curl to No clear error message when calling api with curl and data are not url-encoded
- Severity set to Minor - inconvenience | misleading | easy workaround
- User visibility set to Infrequent - complex configurations | third party integrations
Perhaps we should more clearly document in rudder-api doc that data must be encoded (or just add in curl example the use of -data-urlencode)
Updated by François ARMAND almost 3 years ago
- Target version set to 6.2.13
- Priority changed from 20 to 21
The documentation is
Updated by François ARMAND almost 3 years ago
- Status changed from New to In progress
- Assignee set to François ARMAND
Updated by François ARMAND almost 3 years ago
- Status changed from In progress to Pending technical review
- Assignee changed from François ARMAND to Alexis Mousset
- Pull Request set to https://github.com/Normation/rudder/pull/4141
Updated by François ARMAND almost 3 years ago
- Status changed from Pending technical review to Pending release
Applied in changeset rudder|1e15e58e6ad604fbd6414f3810a9d7d817fda1bd.
Updated by Vincent MEMBRÉ over 2 years ago
- Status changed from Pending release to Released
This bug has been fixed in Rudder 6.2.13, 7.0.2 and 7.1.0~rc1 which were released today.