Skip to content

Make JSON error trapping v2 safe. - #26

Merged
jskress merged 1 commit into
masterfrom
jsk-make-backward-compatible
Jan 21, 2020
Merged

jskress merged 1 commit into
masterfrom
jsk-make-backward-compatible

Conversation

@jskress

@jskress jskress commented Jan 21, 2020 •

Copy link
Copy Markdown

Description

This change updates the API code to use a more general (and Python v2 compliant) exception when testing for JSON decode failures.

Testing Notes / Validation Steps

  • The code will now work correctly under Python 2.x
  • The code will continue to work correctly under Python 3.x

@jskress
jskress merged commit cade453 into master Jan 21, 2020
@jskress
jskress deleted the jsk-make-backward-compatible branch January 21, 2020 17:49
@scottmmjackson scottmmjackson mentioned this pull request Jan 21, 2020
nealrichardson added a commit that referenced this pull request Jun 24, 2026
* feat: add deploy bundle command for downloaded bundles

Add `rsconnect deploy bundle <bundle.tar.gz>` to deploy a previously
built content bundle (such as one downloaded from a Connect server)
directly to a server. The bundle is uploaded as-is; its existing
manifest.json determines the content type and dependencies, making it
easy to copy content between servers.

Rather than extract and re-bundle, this reuses the existing executor
deploy chain: make_bundle simply opens the tarball and deploy_bundle
uploads it unchanged. New bundle.py helpers read the app mode and
default title from the tarball's manifest.json without full extraction.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor: pull git metadata detection out of prepare_deploy_metadata

prepare_deploy_metadata now receives already-detected metadata instead of
a directory to inspect, so callers decide whether to auto-detect git
metadata. The existing deploy commands pass detect_git_metadata(base_dir);
deploy bundle passes an empty dict so no git metadata is auto-attached.

A bundle's location on disk is unrelated to the content's source, so
detecting git metadata from it would attach misleading provenance. Only
explicit --metadata overrides are sent for bundle deployments.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: address review findings for deploy bundle

- default_title_from_bundle now falls back to the bundle's own filename
  (e.g. "mycontent" from "mycontent.tar.gz") when the manifest has no
  usable entrypoint, instead of the directory the bundle happens to live
  in, which is unrelated to the content's identity (roborev #24, medium).
- Add a CLI-level test (test_deploy_bundle) covering the full deploy flow
  and asserting the tarball is uploaded unchanged (roborev #24, low).
- Add unit tests for the filename fallback and a .tar.gz/.tgz extension
  stripping helper.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: preserve dots in bundle filename when deriving default title

A bundle filename like my.cool.api.tar.gz was truncated to "my.cool":
after stripping the archive extension, _default_title ran a second
rsplit(".", 1) on the result. Extract length enforcement into
_enforce_title_length and format the pre-stripped bundle name directly,
so dotted stems are preserved (roborev #26, low).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: address PR review feedback for deploy bundle

- Revert prepare_deploy_metadata to take directory: Optional[str] and
  detect git metadata internally; bundle deployment passes directory=None
  to skip auto-detection, rather than extracting detect_git_metadata to
  every call site.
- Simplify bundle title fallback to only strip .tar.gz (Connect always
  produces .tar.gz bundles), dropping the .tgz/.tar affordance.
- Collapse the metadata assignment in deploy bundle to a single line.
- Move the deploy bundle CHANGELOG entry to the bottom of "Added".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs: explain why open_bundle exists

open_bundle is a no-op "builder" passed to RSConnectExecutor.make_bundle,
which expects a callable returning a file-like bundle. Document that for
deploy bundle the tarball already exists, so we just open() it and route
through make_bundle to reuse the existing deployment-name and upload flow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor: return only parsed manifest from read_bundle_manifest

The raw manifest string was modeled after read_manifest_file, where it is
re-added to a freshly built tarball. deploy bundle uploads the bundle as-is
and never rebuilds it, so every caller discarded the raw string. Return just
the parsed ManifestData.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: locate manifest in nested bundle tarballs

Connect collapses a bundle whose extraction root holds a single subdirectory,
moving its contents up a level and repeating. Downloaded bundles therefore
commonly nest manifest.json under a top-level directory (e.g.
"bundle/manifest.json"). read_bundle_manifest only looked at the tar root, so
deploying such a bundle failed with "does not contain a manifest.json file"
even though Connect would have accepted it.

Mirror Connect's single-subdirectory collapse when locating the manifest, so
app mode and default title are read correctly. The upload path is unchanged:
the bundle is still sent as-is and Connect performs its own collapse.

Reported by @marcosnav in PR review.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants