Project

General

Profile

Actions

Bug #10915

closed

No clear error message when calling api with curl and data are not url-encoded

Added by I C almost 7 years ago. Updated about 2 years ago.

Status:
Released
Priority:
N/A
Category:
API
Target version:
Severity:
Minor - inconvenience | misleading | easy workaround
UX impact:
User visibility:
Infrequent - complex configurations | third party integrations
Effort required:
Priority:
21
Name check:
Fix check:
Checked
Regression:

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",
....

Actions #1

Updated by Benoît PECCATTE almost 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

Actions #2

Updated by François ARMAND almost 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)

Actions #3

Updated by Benoît PECCATTE almost 7 years ago

  • Priority changed from 0 to 6
Actions #4

Updated by Benoît PECCATTE almost 7 years ago

  • Priority changed from 6 to 22
Actions #5

Updated by Benoît PECCATTE over 6 years ago

  • Priority changed from 22 to 20
Actions #6

Updated by François ARMAND about 2 years ago

  • Target version set to 6.2.13
  • Priority changed from 20 to 21

The documentation is

Actions #7

Updated by François ARMAND about 2 years ago

  • Status changed from New to In progress
  • Assignee set to François ARMAND
Actions #8

Updated by François ARMAND about 2 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
Actions #9

Updated by François ARMAND about 2 years ago

  • Status changed from Pending technical review to Pending release
Actions #10

Updated by François ARMAND about 2 years ago

  • Fix check set to Checked
Actions #11

Updated by Vincent MEMBRÉ about 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.

Actions

Also available in: Atom PDF