st2: st2 fails to store a Key-Value in the datastore if there is a "/" in the key name.
SUMMARY
st2 fails to store a Key-Value in the datastore if there is a “/” in the key name. I am sorry if I missed anything in the docs, which says that you cannot store a key with “/” in it and please feel free to close this issue if that is the case. Thank you.
STACKSTORM VERSION
st2 3.1.0, on Python 2.7.5
OS, environment, install method:
CentOS/Docker, custom install.
Steps to reproduce the problem
bash-4.2$ st2 key set "foo / bar" "foo_bar"
ERROR: 404 Client Error: Not Found
MESSAGE: The resource could not be found. for url: http://127.0.0.1:9101/v1/keys/foo%20/%20bar
Expected Results
st2 should have accepted the key-value pair and stored it.
Actual Results
st2 has failed to store the key-value pair.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 18 (8 by maintainers)
Thank you for the input @amanda11. I just tried with double encoding/quoting the key name if it contains a
/while Isetorgetthe KV pair and it is working as expected. If this is OK, I will go ahead and submit a pull request. @Kami @armabgit diff:
I did this little test based on the code in router.py:
So it looks like it gets altered to foo/bar by the url_unquote call.
I believe the webob.compat inturn calls the urllib method, which is defined to be: urllib.parse.unquote(string, encoding=‘utf-8’, errors=‘replace’)¶ Replace %xx escapes by their single-character equivalent. The optional encoding and errors parameters specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method.
So that seems to be the behaviour of the unquote.