Skip to content

Comments

fix: rsconnect list bug#726

Merged
joshyam-k merged 5 commits intomainfrom
jy/list-fix
Nov 20, 2025
Merged

fix: rsconnect list bug#726
joshyam-k merged 5 commits intomainfrom
jy/list-fix

Conversation

@joshyam-k
Copy link
Contributor

@joshyam-k joshyam-k commented Nov 12, 2025

Intent

Resolves #705

Type of Change

  • Bug Fix
  • New Feature
  • Breaking Change

Approach

  • Prevent sorting function called by rsconnect list from being fed a null name. This will provide a fix for any users with currently "corrupted" servers.json files.
  • Make --name a required param for rsconnect add. To me there is no use case for rsconnect add-ing a server with no name as you wouldn't be able to reference it in other commands (like deploy).

Validation

  1. add a server with no name:
rsconnect add -s http://localhost:3939 -k <api-key>
  1. Run rsconnect list
Nickname: "None"
    URL: http://localhost:3939
    API key is saved

Checklist

  • I have updated CHANGELOG.md to cover notable changes.
  • I have updated all related GitHub issues to reflect their current state.

@github-actions
Copy link

github-actions bot commented Nov 12, 2025

PR Preview Action v1.6.2
Preview removed because the pull request was closed.
2025-11-20 19:34 UTC

@github-actions
Copy link

github-actions bot commented Nov 12, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
5260 4004 76% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/metadata.py 91% 🟢
TOTAL 91% 🟢

updated for commit: e4e4846 by action🐍

@joshyam-k joshyam-k requested a review from ChaitaC November 12, 2025 20:14
@joshyam-k joshyam-k assigned tdstein and unassigned tdstein Nov 12, 2025
@joshyam-k joshyam-k requested a review from tdstein November 12, 2025 20:14
@ChaitaC
Copy link

ChaitaC commented Nov 12, 2025

Verified the fix
(rsconnect version : 1.28.1.dev2+g4f49f5bed)

When you have existing entry with server name null

  • Before the fix:
(venv) MacBook-Pro:rsconnect-null-test chaitamacpro$ rsconnect list
Traceback (most recent call last):
  File "/Users/chaitamacpro/Downloads/kubernetes/venv/lib/python3.8/site-packages/rsconnect/actions.py", line 76, in cli_feedback
    yield
  File "/Users/chaitamacpro/Downloads/kubernetes/venv/lib/python3.8/site-packages/rsconnect/main.py", line 758, in list_servers
    servers = server_store.get_all_servers()
  File "/Users/chaitamacpro/Downloads/kubernetes/venv/lib/python3.8/site-packages/rsconnect/metadata.py", line 319, in get_all_servers
    return self._get_sorted_values(lambda s: s["name"])
  File "/Users/chaitamacpro/Downloads/kubernetes/venv/lib/python3.8/site-packages/rsconnect/metadata.py", line 162, in _get_sorted_values
    return sorted(self._data.values(), key=sort_by)
TypeError: '<' not supported between instances of 'NoneType' and 'str'
Internal error: '<' not supported between instances of 'NoneType' and 'str'
  • After the fix
(venv) MacBook-Pro:rsconnect-null-test chaitamacpro$ rsconnect list
Server information from /Users/chaitamacpro/Library/Application Support/rsconnect-python/servers.json

Nickname: "None"
    URL: https://dogfood.team.pct.posit.it/
    API key is saved

Nickname: "dogfood"
    URL: https://dogfood.team.pct.posit.it/
    API key is saved

Nickname: "localhost"
    URL: http://localhost:3939
    API key is saved

Nickname: "testserver"
    URL: https://dogfood.team.pct.posit.it/
    API key is saved

Name is now required arg

(venv) MacBook-Pro:rsconnect-null-test chaitamacpro$ rsconnect add -s https://dogfood.team.pct.posit.it/ -k My_API_KEY

Usage: rsconnect add [OPTIONS]
Try 'rsconnect add --help' for help.

Error: --name is required
(venv) MacBook-Pro:rsconnect-null-test chaitamacpro$ rsconnect add -s https://dogfood.team.pct.posit.it/ -k My_API_KEY -n DogfoodServer 
Checking https://dogfood.team.pct.posit.it/...   [OK]
Checking API key...                              [OK]
Added Connect server "DogfoodServer" with URL https://dogfood.team.pct.posit.it/

Copy link

@ChaitaC ChaitaC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that the PR resolves the initial issue, and all the changes look good to me.

However, since we’re making the name argument required, I’ll leave the final approval to someone more familiar with this part of the code. I can’t think of any scenarios where this change would cause issues.

Do we have any older documentation that explicitly mentioned name as optional? I did a quick check but didn’t find anything.

@joshyam-k
Copy link
Contributor Author

tests against latest version of Connect: https://github.com/posit-dev/connect/actions/runs/19311989599/job/55234313069

Copy link
Collaborator

@tdstein tdstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if multiple entries in servers.json have a value of "None"?

@joshyam-k
Copy link
Contributor Author

What happens if multiple entries in servers.json have a value of "None"?

rsconnect deploy shiny -n None . deploys to whichever server named None exists first in the servers.json file. Not only is deploying to "None" a really weird thing to do, but it's this behavior that made me want to make name required

Copy link
Contributor

@toph-allen toph-allen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's worth adding a server without a name to the tests for list? You would just need to add one without a nickname around line 25, it would be pretty easy.

I manually verified this locally, but it's better to also have a test probably.

I'll approve this now, as functionally it works — better if you add a short test that list works with a no-name server before you merge.

@tdstein
Copy link
Collaborator

tdstein commented Nov 20, 2025

rsconnect deploy shiny -n None . deploys to whichever server named None exists first in the servers.json file. Not only is deploying to "None" a really weird thing to do, but it's this behavior that made me want to make name required

Ok, just wanted to ensure that it didn't blow up if multiple entries have a name of "None".

@joshyam-k joshyam-k requested a review from toph-allen November 20, 2025 18:10
Copy link
Contributor

@toph-allen toph-allen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@joshyam-k joshyam-k merged commit 4b6e2f1 into main Nov 20, 2025
13 checks passed
@joshyam-k joshyam-k deleted the jy/list-fix branch November 20, 2025 19:34
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.

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

4 participants