Skip to content

Conversation

@Nexusrex18
Copy link

@Nexusrex18 Nexusrex18 commented Jan 2, 2026

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

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

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

  • Bug Fixes
    • Improved connection input data processing to correctly handle and flatten nested sequences, ensuring consistent formatting of comma-separated values.

✏️ Tip: You can customize this high-level summary in your review settings.

…#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
@coderabbitai
Copy link

coderabbitai bot commented Jan 2, 2026

📝 Walkthrough

Walkthrough

The input_data property in the connection base models was updated to handle list and tuple arguments by flattening them with comma-separated values before aggregating all arguments into the final output string.

Changes

Cohort / File(s) Summary
Argument processing in input_data property
openwisp_controller/connection/base/models.py
Modified input_data property to convert list and tuple arguments into comma-separated strings, flattening nested sequences before final aggregation

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops with glee,
Lists and tuples now agree!
Flatten, join, and string with care,
Arguments flow everywhere! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding support for list/tuple arguments in custom commands, which aligns with the changeset's core objective.
Description check ✅ Passed The description covers the problem, solution, and references issue #809, but several checklist items remain unchecked despite being part of the template.
Linked Issues check ✅ Passed The PR successfully addresses issue #809 by implementing list/tuple flattening in the input_data property, allowing array-type arguments without TypeError while maintaining backward compatibility.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing issue #809 by safely handling list/tuple arguments in the Command model's input_data property.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d6323bb and cefa9bd.

📒 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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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_data property 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

📥 Commits

Reviewing files that changed from the base of the PR and between d6323bb and cefa9bd.

📒 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

@coveralls
Copy link

Coverage Status

coverage: 98.598% (-0.01%) from 98.612%
when pulling cefa9bd on Nexusrex18:issues/809-custom-command-expects-string-type
into d6323bb on openwisp:master.

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.

[bug] Custom command expects string type

2 participants