Skip to content

Treat all queue names as strings to avoid JSON confusion#1

Open
tbartlett0 wants to merge 2 commits intoACSC-CyberLab:masterfrom
tbartlett0:master
Open

Treat all queue names as strings to avoid JSON confusion#1
tbartlett0 wants to merge 2 commits intoACSC-CyberLab:masterfrom
tbartlett0:master

Conversation

@tbartlett0
Copy link

@tbartlett0 tbartlett0 commented Oct 5, 2018

restq passes or returns queue IDs in JSON mappings (dicts) at a few points. JSON doesn't support numeric indexes in dicts, so the client has no way to know if the original queue ID was a string or an integer.
If the client calls /<realm>/status and sees a queue called str("1"), and then asks to set queue lease time for queue str("1"), but the server actually has a queue called int(1), then the server will create a NEW queue called str("1") and set the lease time on that. The server now has two queues, called int(1) and str("1"), which is both confusing, and also breaks the JSON when you call status again (you get '"queues": {"1": {}, "1": {}}').

This patch converts queue_id to str every time it is passed into the core functions of realms.py, with the result that queue IDs will now always be the string representation of whatever you pass in, and will be valid JSON keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant