psfalcon
psfalcon copied to clipboard
[ BUG ] `400: The ids parameter must be present...` error when using Turkish display language
Describe the bug
When using Turkish as your default display language, the following error is produced when using various PSFalcon commands:
{"code":400,"message":"The \u0027ids\u0027 parameter must be present at least once."}
To Reproduce
Install the Turkish language pack, set it as default, and attempt to use PSFalcon commands like Add-FalconSensorTag, Get-FalconHost -Detailed, etc.
Environment (please complete the following information):
- OS: Windows 10
- PowerShell: 5.1
- PSFalcon: Likely any version
The initial bug report for this issue was specifically related to the Add-FalconSensorTag command, but after some testing I was able to reproduce it with any command that took identifier values and submitted them as part of a Json body.
The issue is due to how Turkish represents an uppercase i and that regex matching in PowerShell is not case insensitive by default when using Turkish (or possibly any language other than English). PSFalcon uses a private function called Build-Content to convert a user's input into a properly formatted Json body, which basically works like this:
- Check user input against the expected format for the related submission to the target API
- If the user's input needs to be renamed (for example, from
Idtoids), check the alias attribute in PowerShell, and use it when present - Compare the users input (i.e.
'ids' -match 'Ids') and add input to the Json body
This failed in Turkish because ids would never match Ids (but does in English). The simplest fix seems to be to update all of the commands to use a lowercase alias when switching Id, to convert it to ids (rather than the current Ids), which will behave as expected. The fix will be included in the next release.