cytoscape / RCy3

New version of RCy3, redesigned and collaboratively maintained by Cytoscape developer community
MIT License
48 stars 20 forks source link

commandsPOST() does not correctly parse arguments #136

Closed mikekucera closed 2 years ago

mikekucera commented 3 years ago

Originally reported here: https://github.com/BaderLab/EnrichmentMapApp/issues/463

The following command, which works in the Command panel, does not work correctly from RCy3...

commandsPOST("enrichmentmap dataset color colors=\"enrichments_A=#440000\"")

The output looks like this...

url=http://localhost:1234/v1/commands/enrichmentmap/dataset%20color
 body={
 "colors": "",
"enrichments_A": "#440000" 
}

It should probably look like this...

url=http://localhost:1234/v1/commands/enrichmentmap/dataset%20color
 body={
 "colors": "enrichments_A=#440000" 
}

Note, I can get it to work by using commandsRun() and URL encoding all the special characters, but that is not ideal.

commandsRun("enrichmentmap dataset color colors=\"enrichments_A%3D%23AA0000\"")

rosscm commented 2 years ago

Hi, I'm just wondering if there's been any development with this bug? Thanks

AlexanderPico commented 2 years ago

Sorry for the delay. There is not an easy fix here. Equal sign is treated like a special character in CyCommands syntax, so I have been reliable splitting on it to parse commands in this R package. Checking for cases where the equal sign is within a parameter is technically possible, I'm sure, but it's a high risk change since I don't have an easy way to test all the existing commands supported for all apps and would worry about creating more bugs than I'm fixing.

Since there is a workaround, I'm hesitant to introduce this risky fix. By the way, the workaround (using URL encoding) is the exact same solution required for curl and URL use cases, e.g.,

curl -X GET --header 'Accept: text/plain' 'http://localhost:1234/v1/commands/enrichmentmap/dataset color?colors=enrichments_A%3D%2300FF00'

http://localhost:1234/v1/commands/enrichmentmap/dataset color?colors=enrichments_A%3D%2300FF00

So, I think the best solution would be to document the need to encode equal signs when automating enrichmentmap.

rosscm commented 2 years ago

Thanks @AlexanderPico, I'll use your solution.