Skip to content

rsconnect-python crashes on rsconnect list when server has null name #705

@ChaitaC

Description

@ChaitaC

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

  1. Create or modify the servers.json file with a null name:
    echo '{"bad_server": {"url": "https://example.com", "name": null}}' > ~/.rsconnect-python/servers.json
  2. Run rsconnect list
  3. Observe the crash with TypeError
Image

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:

  1. Handle None values in the sort key:
    In get_all_servers()
    return self._get_sorted_values(lambda s: s["name"] or "")

  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions