Skip to content

🧪 Add test for invalid snapshot JSON manifest structure#5

Merged
bashandbone merged 3 commits intomainfrom
fix/snapshot-invalid-json-test-13016918876953013802
Mar 13, 2026
Merged

🧪 Add test for invalid snapshot JSON manifest structure#5
bashandbone merged 3 commits intomainfrom
fix/snapshot-invalid-json-test-13016918876953013802

Conversation

@bashandbone
Copy link
Contributor

🎯 What: The testing gap addressed was testing the TypeError exception path in SnapshotManager.read_manifest() when the JSON manifest is parsed but has an invalid structure for SnapshotEntry instantiation.
📊 Coverage: The scenario where a valid JSON file is parsed, but its contents lack the required keys (source, stored) for entries, causing a TypeError, is now explicitly tested. Also fixed an existing test failure related to pre-3.12 type alias detection.
Result: Test coverage for src/exportify/common/snapshot.py is improved, achieving robust handling of invalid manifest structures and guaranteeing read_manifest accurately returns None.


PR created automatically by Jules for task 13016918876953013802 started by @bashandbone

Added `test_read_manifest_returns_none_on_invalid_entry_format` to test
that reading a snapshot manifest with broken JSON data (specifically missing
required keys for `SnapshotEntry` causing a `TypeError`) safely returns `None`.

Also corrected `tests/fixtures/sample_type_aliases.py` to use `TypeAlias`
from `typing` for pre-3.12 alias detection tests.

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings March 13, 2026 02:25
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds regression coverage for SnapshotManager.read_manifest() when the manifest JSON parses but can’t be converted into SnapshotEntry objects, and updates a type-alias fixture to properly represent “pre-3.12” alias syntax.

Changes:

  • Add a test that exercises the TypeError path when manifest entries are missing required SnapshotEntry fields.
  • Update the type-alias fixture to use X: TypeAlias = Y for pre-3.12 style aliases.

Reviewed changes

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

File Description
tests/test_snapshot.py Adds a new test covering invalid manifest entry structure (TypeError during SnapshotEntry(**e)).
tests/fixtures/sample_type_aliases.py Adjusts the fixture to use TypeAlias assignments for pre-3.12 style aliases.

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

Comment on lines +18 to +22
@@ -19,14 +19,16 @@
# Dummy usage of type aliases to keep static analyzers happy.
test_file_path: FilePath | None = None

from typing import TypeAlias
Added an exception in `ruff.toml` for `UP040` on `tests/fixtures/sample_type_aliases.py`
to prevent the linter from complaining about the use of `TypeAlias` since it is
intentionally used for backward-compatibility testing.

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
type ErrorMessage = str
type ConfigDict = dict[str, str | int | bool | list[str]]
type NamePair = tuple[str, str]
FilePath: TypeAlias = str | Path
…3013802

Signed-off-by: Adam Poulemanos <89049923+bashandbone@users.noreply.github.com>
@bashandbone bashandbone merged commit db0e3e6 into main Mar 13, 2026
5 of 9 checks passed
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.

3 participants