Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rsconnect/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,12 @@ def add(
set_verbosity(verbose)
output_params(ctx, locals().items())

if not server and not any([token, secret, account]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this belong inside validate_connection_options (below)?

Copy link
Contributor Author

@joshyam-k joshyam-k Feb 24, 2026

Choose a reason for hiding this comment

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

it probably could, but it would require a decent amount of additional complexity because validate_connection_options is used across commands. We can't just blindly reject name only inputs in it because commands like rsconnect deploy -n my-server are perfectly valid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, that's sad. Ok.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Too much sadness in this pull request.

raise RSConnectException(
"`rsconnect add` requires -s/--server (for Posit Connect) or -A/--account, -T/--token, "
"and -S/--secret (for shinyapps.io)."
)

validation.validate_connection_options(
ctx=ctx,
url=server,
Expand Down
22 changes: 22 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,28 @@ def test_add_shinyapps(self):
if original_server_value:
os.environ["CONNECT_SERVER"] = original_server_value

def test_add_name_only_missing_server_and_credentials(self):
"""Regression test: `rsconnect add -n x` should produce a validation error, not a TypeError."""
original_api_key_value = os.environ.pop("CONNECT_API_KEY", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

It makes me sad that you have to do this env management in every test manually.

original_server_value = os.environ.pop("CONNECT_SERVER", None)
try:
runner = CliRunner()
result = runner.invoke(
cli,
[
"add",
"--name",
"some-name",
],
)
assert result.exit_code == 1, result.output
assert "`rsconnect add` requires" in str(result.exception)
finally:
if original_api_key_value:
os.environ["CONNECT_API_KEY"] = original_api_key_value
if original_server_value:
os.environ["CONNECT_SERVER"] = original_server_value

def test_add_shinyapps_missing_options(self):
original_api_key_value = os.environ.pop("CONNECT_API_KEY", None)
original_server_value = os.environ.pop("CONNECT_SERVER", None)
Expand Down
2 changes: 1 addition & 1 deletion vetiver-testing/vetiver-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pandas
numpy
pydantic
pydantic<2
pytest
pins
vetiver
Loading