St2: Webhooks with '/' in them don't get routed to the controller

Created on 6 Apr 2018  路  1Comment  路  Source: StackStorm/st2

CLI logs

(virtualenv) root@80fa4dcc1299:/st2# st2 --debug webhook get devices/config
# -------- begin 140399977822608 request ----------
curl -X GET -H  'Connection: keep-alive' -H  'Accept-Encoding: gzip, deflate' -H  'Accept: */*' -H  'User-Agent: python-requests/2.14.2' http://127.0.0.1:9101/v1/webhooks/devices/config
# -------- begin 140399977822608 response ----------
{
    "faultstring": "The resource could not be found."
}
# -------- end 140399977822608 response ------------

Webhook "devices/config" is not found.

CLI settings:
----------------
Config file path: /root/.st2/config
Client settings:
----------------
ST2_BASE_URL: http://127.0.0.1
ST2_AUTH_URL: http://127.0.0.1:9100
ST2_API_URL: http://127.0.0.1:9101/v1
ST2_STREAM_URL: http://127.0.0.1:9102/v1
ST2_AUTH_TOKEN: None

Proxy settings:
---------------
HTTP_PROXY:
HTTPS_PROXY:

Traceback (most recent call last):
  File "/st2/st2client/st2client/shell.py", line 343, in run
    func(args)
  File "/st2/st2client/st2client/commands/resource.py", line 334, in run_and_print
    raise OperationFailureException('Resource %s not found.' % resource_id)
OperationFailureException: Resource devices/config not found.
(virtualenv) root@80fa4dcc1299:/st2#

API logs

2018-04-06 16:21:38,093 140341107055824 DEBUG router [-] Match path: /v1/webhooks/devices/config
2018-04-06 16:21:38,095 140341107055824 DEBUG error_handling [-] API call failed: None (exception_message='The resource could not be found.',exception_data={'comment': None, '_headers': None, 'conditional_response': False, 'detail': None, '_app_iter': [''], '_status': '404 Not Found', '_headerlist': [('Content-Type', 'text/html; charset=UTF-8'), ('Content-Length', '0')]},exception_class='HTTPNotFound')
2018-04-06 16:21:38,098 140341107055824 DEBUG error_handling [-] Traceback (most recent call last):
  File "/st2/st2common/st2common/middleware/error_handling.py", line 49, in __call__
    raise exc.HTTPNotFound()
HTTPNotFound: The resource could not be found.

2018-04-06 16:21:38,099 140341107055824 DEBUG router [-] Match path: /v1/webhooks/devices/config
2018-04-06 16:21:38,101 140341107055824 INFO logging [-] 627fc307-795f-42b3-9580-be1e6bd062bb - 404 57 9.845ms (content_length=57,request_id='627fc307-795f-42b3-9580-be1e6bd062bb',runtime=9.845,remote_addr='127.0.0.1',status=404,method='GET',path='/v1/webhooks/devices/config')
2018-04-06 16:21:38,102 140341107055824 DEBUG logging [-] 627fc307-795f-42b3-9580-be1e6bd062bb - 404 57 9.845ms
{
    "faultstring": "The resource could not be found."
} (result='{\n    "faultstring": "The resource could not be found."\n}',content_length=57,request_id='627fc307-795f-42b3-9580-be1e6bd062bb',runtime=9.845,remote_addr='127.0.0.1',status=404,method='GET',path='/v1/webhooks/devices/config')
bug regression

>All comments

Based on my research it would appear OpenAPI does not support defining a parameter that could contain one or more slashes. Likewise it does not appear that routes module we use supports it either.

We could override some of the routes classes and implement our own parsing there, but that is coupled with it's own pros/cons. We could rip/replace routes and/or OpenAPI but this is just impractical. Our two options are either 1) Remove support for further /s or 2) Override the class and implement our own handling of parameters.

Either way I'm going to put this away for today. Can readdress later.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pietervogelaar picture pietervogelaar  路  4Comments

nmaludy picture nmaludy  路  7Comments

bigmstone picture bigmstone  路  8Comments

pietervogelaar picture pietervogelaar  路  5Comments

nbaillie picture nbaillie  路  6Comments