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
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Follows symlinks when bundling content: linked files are archived with their target contents and linked directories are included, instead of archiving broken links or omitting the directories. [#955](https://github.com/posit-dev/rsconnect-python/pull/955)
- Passes `--package-installer` through in `write-manifest <framework>` and `deploy quarto`. The option was accepted but ignored, so the manifest always recorded `pip`. [#877](https://github.com/posit-dev/rsconnect-python/pull/877)
- `system caches delete` exits with status 1 when the Connect task that deletes the cache fails. [#876](https://github.com/posit-dev/rsconnect-python/pull/876)

## [1.33.2] - 2026-11-10

Expand Down
2 changes: 1 addition & 1 deletion rsconnect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2995,7 +2995,7 @@ def delete_runtime_cache(self, language: str, version: str, image_name: str, dry
print("Dry run finished")
return result, None
else:
(_, task) = self.client.wait_for_task(result["task_id"], connect_logger.info, raise_on_error=False)
(_, task) = self.client.wait_for_task(result["task_id"], connect_logger.info)
return result, task


Expand Down
60 changes: 60 additions & 0 deletions tests/test_main_system_caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,66 @@ def test_system_caches_delete_happy_path(self):
self.assertEqual(body["version"], "1.2.3")
self.assertEqual(body["image_name"], "Local")

@httpretty.activate(verbose=True, allow_net_connect=False)
def test_system_caches_delete_task_failed(self):
"""A task that finishes with a non-zero code is surfaced as exit code 1."""
register_server_validation_uris(CONNECT_SERVER)
httpretty.register_uri(
httpretty.DELETE,
f"{CONNECT_SERVER}/__api__/v1/system/caches/runtime",
status=200,
body=json.dumps(
{"language": "Python", "version": "1.2.3", "image_name": "Local", "dry_run": False, "task_id": "abc123"}
),
adding_headers={"Content-Type": "application/json"},
)
httpretty.register_uri(
httpretty.GET,
f"{CONNECT_SERVER}/__api__/v1/tasks/abc123",
body=json.dumps(
{
"id": "abc123",
"output": [],
"result": {"type": "", "data": ""},
"finished": True,
"code": 1,
"error": "failed to delete cache",
"last": 0,
}
),
adding_headers={"Content-Type": "application/json"},
)

runner = CliRunner()
args = ["system", "caches", "delete", "--language", "Python", "--version", "1.2.3", "--image-name", "Local"]
apply_common_args(args, server=CONNECT_SERVER, key=API_KEY)
result = runner.invoke(cli, args)

self.assertEqual(result.exit_code, 1, result.output)
self.assertRegex(result.output, "Task exited with status 1.")

@httpretty.activate(verbose=True, allow_net_connect=False)
def test_system_caches_delete_dry_run(self):
"""A dry run has no task to wait for and exits 0."""
register_server_validation_uris(CONNECT_SERVER)
httpretty.register_uri(
httpretty.DELETE,
f"{CONNECT_SERVER}/__api__/v1/system/caches/runtime",
status=200,
body=json.dumps(
{"language": "Python", "version": "1.2.3", "image_name": "Local", "dry_run": True, "task_id": None}
),
adding_headers={"Content-Type": "application/json"},
)

runner = CliRunner()
args = ["system", "caches", "delete", "--language", "Python", "--version", "1.2.3", "--image-name", "Local"]
args.append("--dry-run")
apply_common_args(args, server=CONNECT_SERVER, key=API_KEY)
result = runner.invoke(cli, args)

self.assertEqual(result.exit_code, 0, result.output)

def test_system_caches_delete_missing_all_flags(self):
"""Omitting both --language and --version yields exit code 2 (Click validation)."""
runner = CliRunner()
Expand Down
Loading