fix(bundler): wrap invalid YAML from a zipped bundle manifest - #3958
Open
marcelsafin wants to merge 2 commits into
Open
fix(bundler): wrap invalid YAML from a zipped bundle manifest#3958marcelsafin wants to merge 2 commits into
marcelsafin wants to merge 2 commits into
Conversation
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>
Contributor
There was a problem hiding this comment.
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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Installing a bundle from a
.zipparsesspeckit-bundle.ymlwith a bareyaml.safe_load()on the zip byte stream, so an invalid-YAML or non-UTF-8 manifest crashesspecify bundle installwith a raw traceback instead of aBundlerError. The directory-install path already reports these as clean errors via the sharedyamliohelpers, and the zip open/read errors themselves were wrapped by #3141 — only the parse step was left bare.Fix: wrap
safe_loadintry/except yaml.YAMLErrorand raiseBundlerErrorwith the sameInvalid YAMLwording as theyamliocontract. PyYAML reports undecodable bytes from a byte stream asReaderError(aYAMLErrorsubclass), so one clause covers both corruption modes.Testing
uv run specify --helpuv sync && uv run pytest(6,311 passed, 176 skipped)ruff check src testscleanAI Disclosure
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-bytrailers.