CumulusCI
CumulusCI copied to clipboard
add_permission_set_perms throws 'string indices must be integers' error
Describe the bug
The task 'add_permission_set_perms' expects a list of permissions. If you give it a single dictionary rather than a list of dictionaries the task will fail with the useless error message TypeError: string indices must be integers
Reproduction steps
We encountered this error when running the task from a robot test. The test looked like this:
Run task add_permission_set_perms
... api_names=Admissions_Connect_Verifier
... field_permissions=${{ {"field": "Due_Date__c", "editable": True} }}
Robot lets you use arbitrary python code between ${{ and $}}. In this case, field_permissions is being set to the dictionary {"field": "Due_Date__c", "editable": True}. The task expects a list of dictionaries, so the correct way would be to do this:
... field_permissions = ${{ [{"field": "Due_Date__c", "editable": True}] }}
Context
- CumulsuCI version: 3.29.0
- Python version: 3.8.7
- OS: OSX Catalina (10.15.7)
Additional information
The code is assuming the field_permissions parameter is a list of dictionaries without validating that assumption. We should either throw a more human-friendly error message (eg: "field_permissions was expected to be a list, but was a dictionary") or we could be liberal in what we accept and gracefully accept a single dictionary.
This isn't a blocker since the problem only appears when the task is called incorrectly.
Tracking as W-10502960