Skip to content

fix(bundler): wrap invalid YAML from a zipped bundle manifest - #3958

Open
marcelsafin wants to merge 2 commits into
github:mainfrom
marcelsafin:fix/bundle-zip-manifest-yaml
Open

fix(bundler): wrap invalid YAML from a zipped bundle manifest#3958
marcelsafin wants to merge 2 commits into
github:mainfrom
marcelsafin:fix/bundle-zip-manifest-yaml

Conversation

@marcelsafin

Copy link
Copy Markdown
Contributor

Description

Installing a bundle from a .zip parses speckit-bundle.yml with a bare yaml.safe_load() on the zip byte stream, so an invalid-YAML or non-UTF-8 manifest crashes specify bundle install with a raw traceback instead of a BundlerError. The directory-install path already reports these as clean errors via the shared yamlio helpers, and the zip open/read errors themselves were wrapped by #3141 — only the parse step was left bare.

Fix: wrap safe_load in try/except yaml.YAMLError and raise BundlerError with the same Invalid YAML wording as the yamlio contract. PyYAML reports undecodable bytes from a byte stream as ReaderError (a YAMLError subclass), so one clause covers both corruption modes.

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest (6,311 passed, 176 skipped)
  • Two new regression tests (invalid YAML + non-UTF-8 manifest bytes in a zip; both fail on main, pass with fix)
  • ruff check src tests clean

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

Implemented autonomously by GitHub Copilot CLI (model: Claude Fable 5) under human direction; TDD (failing test first), full suite and lint verified locally. Commit includes Assisted-by/Co-authored-by trailers.

Installing a bundle from a .zip parsed speckit-bundle.yml with a bare
yaml.safe_load() on the zip byte stream, so an invalid-YAML or
non-UTF-8 manifest crashed 'specify bundle install' with a raw
traceback instead of a BundlerError. The directory-install path
already reports these as clean errors via the shared yamlio helpers,
and the zip open/read errors themselves were wrapped by github#3141 — only
the parse step was left bare.

Wrap safe_load in try/except yaml.YAMLError and raise BundlerError
with the same 'Invalid YAML' wording as the yamlio contract. PyYAML
reports undecodable bytes from a byte stream as ReaderError (a
YAMLError subclass), so one clause covers both corruption modes.

Assisted-by: GitHub Copilot (model: claude-fable-5, autonomous)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 3, 2026 19:55
@marcelsafin
marcelsafin requested a review from mnriem as a code owner August 3, 2026 19:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Wraps ZIP bundle-manifest YAML parsing failures in BundlerError.

Changes:

  • Handles malformed or undecodable ZIP manifest data.
  • Adds regression tests for malformed YAML and invalid encoding.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/specify_cli/commands/bundle/__init__.py Wraps ZIP manifest parsing errors.
tests/integration/test_bundler_local_install.py Tests YAML and decoding failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/specify_cli/commands/bundle/__init__.py
Review follow-up: feeding PyYAML the byte stream let its Reader honour
a UTF-16 BOM and accept a manifest yamlio.load_yaml rejects, so zip and
directory sources diverged. Decode raw as UTF-8 (UnicodeError ->
BundlerError 'Could not read ...') then parse, and cover a well-formed
UTF-16 manifest in the regression tests.

Assisted-by: GitHub Copilot (model: claude-fable-5, autonomous)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 3, 2026 20:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

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