Skip to content

Keep Connect Cloud secrets on redeploy with -E - #913

Closed
vrsarah wants to merge 2 commits into
mainfrom
fix/connect-cloud-keep-secrets
Closed

vrsarah wants to merge 2 commits into
mainfrom
fix/connect-cloud-keep-secrets

Conversation

@vrsarah

@vrsarah vrsarah commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Deploying to Posit Connect Cloud with -E deleted every secret that -E did not name, including secrets added in the Connect Cloud UI. This happened because PATCH /contents/{id} replaces the whole secret set.

Now, when the content already exists, prepare_deploy() also sends the content's other secrets with a None value, which keeps them. Deploys without -E, and creating new content, are unchanged.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-30 15:46 UTC

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
11038 9739 88% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/api.py 89% 🟢
TOTAL 89% 🟢

updated for commit: 4dca9ff by action🐍

@vrsarah
vrsarah requested review from karawoo and samperman October 29, 2026 20:32
Comment thread rsconnect/api.py
# The PATCH replaces the whole secret set, so send the content's other
# secrets with a None value to keep them, including ones added in the
# Connect Cloud UI.
if secrets is not None and env_vars:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

secrets is only non-None when env_vars is non-empty, so if secrets is not None: would be enough

@nealrichardson

Copy link
Copy Markdown
Contributor

This happened because PATCH /contents/{id} replaces the whole secret set

That doesn't sound like PATCH semantics to me, sounds more like a PUT. Are you sure the fix for this isn't on the server side?

@samperman

Copy link
Copy Markdown
Collaborator

This happened because PATCH /contents/{id} replaces the whole secret set

That doesn't sound like PATCH semantics to me, sounds more like a PUT. Are you sure the fix for this isn't on the server side?

It's a PATCH of content, so replacing the array value of secrets seems semantically OK. But I think there's a server-side change that means we don't need to change these clients at all: keep any secret that isn't named in the list, and add an explicit way to delete one. We'd have to coordinate the API change with the UI, which deletes by leaving secrets out today.

It would change PATCH for API callers that delete secrets by leaving them out; their deletes would stop working. We can check our logs to see whether anyone besides the UI and the deploy clients does that.

I approved this PR, but I changed my mind; Neal has convinced me :)

@vrsarah

vrsarah commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Agreed. We're changing the Connect Cloud API so that PATCH keeps any secret that isn't in the list, with a separate endpoint for deleting secrets. That fixes released clients without an upgrade, so I'm closing this PR.

@vrsarah vrsarah closed this Oct 30, 2026
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.

3 participants