Skip to content

Conversation

@nealrichardson
Copy link
Collaborator

@nealrichardson nealrichardson commented Oct 10, 2025

Intent

Remove calls to unversioned APIs in service of managing the git-backedness of content.

Fixes #416
Fixes #278

Approach

Initially added tryCatches and fallbacks to the v0 APIs, but that didn't work out across the board because in the v1 APIs, 404 on GET means that the content is not git backed, not that the v1 API is unavailable. Since the v1s have been around for 3 years, we've decided to just drop the v0 fallbacks.

I also added some mock tests for the main code paths. There is some amount of coverage coming from the integration tests, which I did not substantively alter.

Checklist

  • Does this change update NEWS.md (referencing the connected issue if necessary)?
  • Does this change need documentation? Have you run devtools::document()?

@nealrichardson
Copy link
Collaborator Author

CI is no longer failing but that does not mean there is enough test coverage for this yet.

In poking at this some more, there are some semantic differences in how the v1 and v0 APIs work. Importantly, "this content is not git backed" is indicated if GET v1/content/guid/repository returns 404. But presumably if you were on a version of Connect that didn't have this API, you would also get 404 from that request regardless of whether it was git backed. So that makes it hard to actually try the v1 API and fall back to v0 if it is not available--basically, every time you fetch this for a non-git-backed content item, you will have to make 2 requests just to see that it is not.

Since the v1 APIs have been around since October 2022, we might just want to make a clean break here and swap over to the v1 APIs with no fallback. We could try to be more clever and detect server version, though that's known to be imperfect, and maybe it's not worth it? 2022 is well outside the support window. So I'm leaning towards just dropping the v0 entirely.

Thoughts @toph-allen @karawoo @jonkeane ?

@karawoo
Copy link
Contributor

karawoo commented Oct 10, 2025

I'm a 👍 on dropping the V0

"variants"
)
guid <- self$get_content()$guid
url <- unversioned_url("applications", guid, "variants")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is just reformatting so that I can see the whole URL on one line--helps to grep the repo to find the remaining v0 endpoints in use.

@nealrichardson nealrichardson marked this pull request as ready for review October 11, 2025 19:04
Copy link
Collaborator

@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.

A few questions or requests about patterns, and one about version checks. Other than that, it looks good, and thanks for moving this forward.

R/content.R Outdated
polling = FALSE
) {
guid <- self$get_content()$guid
self$get_connect()$PUT(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self$get_connect()$PUT(
self$connect$PUT(

R/content.R Outdated
#' - last_error
#' - last_known_commit
repository = function() {
con <- self$get_connect()
Copy link
Collaborator

Choose a reason for hiding this comment

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

At a cursory glance, it looks like the v1 repo endpoints were added in 2024.05.0. Should we add a version check or do something else for back compat here? (ref)

[edit] I could be wrong about that date! The integration tests seem to suggest stuff's fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Judging from https://github.com/posit-dev/connect/issues/22252, they were actually added in October 2022. We just didn't document them until 2024.05 (https://github.com/posit-dev/connect/issues/26982) 🤦

Copy link
Collaborator

@toph-allen toph-allen Oct 15, 2025

Choose a reason for hiding this comment

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

Aaaah that explains my confusion. Thanks!

Still — perhaps good to error_if_less_than() here?

Copy link
Collaborator

@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.

Approving contingent on the $get_content() -> $content changes — no need to re-request review after you've made those! :)

@nealrichardson nealrichardson merged commit e4d9a7a into main Oct 17, 2025
22 checks passed
@nealrichardson nealrichardson deleted the rm-v0-content-repo branch October 17, 2025 21:01
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.

refactor: remove last call of /applications/id Implement Git repository settings using public git APIs

4 participants