Skip to content

Refuse a deployment record whose server is not trusted - #550

Draft
jat255 wants to merge 8 commits into
mainfrom
jat255/t9jb-record-server-check
Draft

jat255 wants to merge 8 commits into
mainfrom
jat255/t9jb-record-server-check

Conversation

@jat255

@jat255 jat255 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

This PR makes trajectory_read() send CONNECT_API_KEY to the server in a project's deployment record only when that server is trusted, so a cloned project cannot choose where your key goes. A server is trusted when it is CONNECT_SERVER, or, when CONNECT_SERVER is unset, when it is a Connect server you registered with rsconnect. The read refuses any other record before it sends a request.

Agent-written details
  • kata: t9jb.
  • The check applies with no source, and when a GUID source takes its server from the record. On Connect itself and for a URL source, nothing changes.
  • With several records, the read uses the newest record whose server is trusted. If none is trusted, it refuses the newest one.
  • The error names the record file and its server, and says to set CONNECT_SERVER and CONNECT_API_KEY for that server. It suggests no URL to pass as source, because the current key would be sent with it. In Python, the error for an rsconnect-python record with several deployments that CONNECT_SERVER cannot choose between also no longer suggests a URL.
  • Each package reads the registry of its own deploy tool: rsconnect-python's servers.json in Python, and rsconnect::accounts() in R. A server registered only with the other tool is refused until CONNECT_SERVER is set. R without rsconnect installed refuses every record when CONNECT_SERVER is unset.
  • Servers are compared with the record server keys: scheme and host ignore case, and everything else must match exactly. So https://x and https://x:443 are different servers. Both keys now keep a query as written.
  • The cases are in the null_deployment, guid_server and record_search sections of the shared fixture.

R changes

trajectory_read() now refuses a project's rsconnect record whose server is not trusted, before it sends the API key there. With CONNECT_SERVER set, the record must name that server. With it unset, the record must name a server in rsconnect::accounts(), where before any record's server was used. The same rule applies when a GUID source takes its server from the record, and with several records the newest trusted one is used ahead of a newer untrusted one. The change has a NEWS bullet.

Issue Fix Code
A cloned project's deployment record chose where CONNECT_API_KEY was sent The read refuses a record whose server is not CONNECT_SERVER or, with that unset, a registered server trajectory-read.R
A newer record for another server hid an older record for CONNECT_SERVER The read uses the newest trusted record trajectory-read.R
deployment_server_key() lowercased a query that followed the host directly It keeps the query as written trajectory-read.R

With no source off Connect, trajectory_read() sent CONNECT_API_KEY to the
server a project's deployment record names, so a cloned project could choose
where the key goes. When CONNECT_SERVER is set and the record names another
server, both readers now refuse before any request and point at the content
URL. A GUID source already prefers CONNECT_SERVER to the record.
A record whose server adds a query to CONNECT_SERVER's passed the check in
Python, since the server key dropped the query. The key now keeps everything
after the host.
Python's key dropped an empty query, and R's lowercased a query that follows
the host. Both keys now take everything after the host as written.
@jat255 jat255 added bug Something isn't working r Affects the R implementation py Affects the Python implementation needs-manual-review Agent-created work that needs a human review labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployed to Connect (dogfood.team.pct.posit.it): https://dogfood.team.pct.posit.it/connect/#/apps/d7a36cae-8f27-448b-a478-61b81fbe3942/draft/393083

Deployed from commit 4732f54.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployed to Connect (connect.staging.pct.posit.it): https://connect.staging.pct.posit.it/connect/#/apps/ad662e1b-5048-4acc-9ad7-f9478c92274e/draft/5341

Deployed from commit 4732f54.

@github-actions

Copy link
Copy Markdown
Contributor

Preview root: https://posit-dev.github.io/commons/pr-550/

Python site preview: https://posit-dev.github.io/commons/pr-550/py/

Built from the latest commit on this branch. The R links in it point at the published R site, which no pull request rebuilds.

A deployment record may send CONNECT_API_KEY only to CONNECT_SERVER or,
when that is unset, to a Connect server registered with the package's
deploy tool, for GUID sources too. With several records, the newest
trusted one is read. The refusal says to set CONNECT_SERVER and
CONNECT_API_KEY for the record's server instead of suggesting a content
URL. connect-source.json pins the new cases, including a tab in the
host.
Neither server in an ambiguous rsconnect-python record need be trusted,
so the message now says to set CONNECT_SERVER and CONNECT_API_KEY for
one of them, as the untrusted-record refusal does.
CONNECT_SERVER cannot pick between rsconnect-python entries whose server
URLs differ only in form, so the error asks for a content GUID instead.
A GUID source reads the ambiguous record again unless CONNECT_SERVER is
set, so the GUID alone does not resolve it.
@jat255 jat255 changed the title Refuse a deployment record whose server is not CONNECT_SERVER Refuse a deployment record whose server is not trusted Nov 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working needs-manual-review Agent-created work that needs a human review py Affects the Python implementation r Affects the R implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant