Repository navigation
Report a malformed JSON import instead of crashing [patch] - #208
Merged
Merged
Conversation
ImportJson caught nothing, so a truncated file, an object instead of an array, or a field of the wrong type ended the process with a stack trace (and ended the interactive menu with it). It now catches JsonException and the ArgumentException a semantic type throws on validation, prints an error naming the file, and returns null so Run fails before anything is merged or saved, the way the CSV path already skips bad rows. Fixes #172 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EizTraGREbkNoiWDb3o9eC
A relative KnownPaths entry makes the AbsoluteFilePath conversion throw ArgumentException, which is the second catch in ImportJson; the test now exercises it alongside the three JsonException cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EizTraGREbkNoiWDb3o9eC
|
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.



Summary
Import.ImportJsoncaught nothing, so any JSON file that failed to deserialize (an object at the root, a truncated array,"FileSizeBytes":"abc") ended the process with a stack trace, and ended the interactive menu session along with it.ImportJsonnow catchesJsonException, plus theArgumentExceptiona semantic type throws when validation fails. It printsError: <file> is not a valid ImageDescriber JSON export: <message>and returnsnull, soRunsetsFailedand returns beforeMergeEntriesorProgram.Settings.Save(). The store is left untouched and the exit code is 1. This matches how the CSV path already handles malformed rows.Tests
ImportTests.RunReportsAMalformedJsonFileWithoutThrowingOrChangingTheStorecovers the three inputs from the acceptance criteria. For each one it asserts that the run fails without throwing, adds nothing to the store, and prints an error that names the file.JsonException. With the fix, they pass.ScanForImagesSkipsUnreadableSubdirectories, which is inconclusive when run as root).Fixes #172
🤖 Generated with Claude Code
https://claude.ai/code/session_01EizTraGREbkNoiWDb3o9eC
Generated by Claude Code