-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Issue
The rsconnect list command crashes with TypeError: '<' not supported between instances of 'str' and 'NoneType' when a server entry has a null/None value for its name field.
Re Slack thread: https://positpbc.slack.com/archives/CCD5REGR4/p1756228912248909
Reproduction Steps
- Create or modify the servers.json file with a null name:
echo '{"bad_server": {"url": "https://example.com", "name": null}}' > ~/.rsconnect-python/servers.json - Run rsconnect list
- Observe the crash with TypeError
FROM Claude:
The _get_sorted_values() method in metadata.py uses Python's sorted() function without handling the case where some values might be None. When
sorting server entries by name, any entry with a null name will cause the sort comparison to fail.
Suggested Fix
Apply one of these solutions:
-
Handle None values in the sort key:
In get_all_servers()
return self._get_sorted_values(lambda s: s["name"] or "") -
Add defensive handling in _get_sorted_values:
def _get_sorted_values(self, sort_by):
def safe_sort(item):
key = sort_by(item)
return key if key is not None else ""
return sorted(self._data.values(), key=safe_sort)
Additional Notes
- This likely happens when server entries are manually edited or created with a null name
- The set() method should validate that the name is not None before storing
- Consider adding validation elsewhere to prevent null values in required fields