-
-
Notifications
You must be signed in to change notification settings - Fork 247
[connection] Support list/tuple arguments in custom commands #809 #1188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[connection] Support list/tuple arguments in custom commands #809 #1188
Conversation
…#809 The input_data property previously used ', '.join(self.arguments) directly, causing TypeError when arguments are lists. This change safely flattens list/tuple arguments to comma-separated strings and converts all items to str, preventing the error while preserving backward compatibility. Fixes openwisp#809
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
openwisp_controller/connection/base/models.py (1)
638-648: Logic correctly handles list/tuple arguments; verify test coverage exists.The implementation properly addresses the TypeError by detecting list/tuple arguments and flattening them with comma-separated values before the final join. The approach is backward compatible—string arguments continue to work as before.
However, no dedicated tests were found for the
input_dataproperty with list/tuple arguments. Confirm that tests covering this feature have been added, including:
- List/tuple argument handling (e.g., input with array-type properties like checkboxes)
- Edge cases: empty lists, nested structures, mixed argument types
- API response formatting with flattened arguments
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
openwisp_controller/connection/base/models.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Python==3.13 | django~=5.2.0
- GitHub Check: Python==3.12 | django~=5.1.0
- GitHub Check: Python==3.12 | django~=4.2.0
- GitHub Check: Python==3.10 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=5.1.0
- GitHub Check: Python==3.13 | django~=5.1.0
- GitHub Check: Python==3.10 | django~=4.2.0
- GitHub Check: Python==3.12 | django~=5.2.0
- GitHub Check: Python==3.11 | django~=4.2.0
- GitHub Check: Python==3.10 | django~=5.2.0
- GitHub Check: Python==3.11 | django~=5.2.0
The current implementation of the input_data property in the Command model
uses ', '.join(self.arguments) directly, which raises TypeError when an
argument is a list (e.g., from array schema properties like checkboxes).
This change adds safe handling by checking if each argument is a list or tuple,
flattening it to a comma-separated string, and converting all items to str.
This prevents the TypeError while maintaining backward compatibility for
string arguments and enables proper use of array types in user-registered
custom command schemas.
Fixes #809
Checklist
Reference to Existing Issue
Closes #.
Please open a new issue if there isn't an existing issue yet.
Description of Changes
Please describe these changes.
Screenshot
Please include any relevant screenshots.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.