Keep scanning when one file or one model response fails - #155
Merged
Merged
Conversation
HashFiles let an IOException from one unreadable or dangling file escape Parallel.ForEach, and the describe loop caught only HttpRequestException, so a non-JSON response, a request timeout or a file vanishing after hashing ended the whole run with an unhandled AggregateException. HashFiles now warns about and leaves out a file it cannot read. The describe phase moves into Scan.DescribeImages, which logs and collects per-image failures, including JsonException, the timeout's OperationCanceledException and IOException, and carries on with the other images. Scan then prints a summary of what failed. Fixes #150 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0113g7mUxeizhTrH6na279Ez
Runs the Scan verb against the fake Ollama endpoint with an image the server answers with HTML, and checks that the run completes and reports the failure. This covers the new code in Scan.Run that DescribeImages' own test cannot reach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0113g7mUxeizhTrH6na279Ez
SonarCloud flagged Scan.Run's cognitive complexity (16, limit 15) once it printed the summary inline. Also switch the new tests to Assert.HasCount and Assert.Contains, as the MSTest analyzers suggest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0113g7mUxeizhTrH6na279Ez
|
3 tasks
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.



Fixes #150
Summary
In both parallel phases of
Scan, one failed item ended the whole run with an unhandledAggregateException.ImageHasher.HashFilescatchesIOExceptionandUnauthorizedAccessExceptionfor each file, prints a warning, and leaves that file out of the results. This covers dangling symlinks and locked or permission-denied files.Scan.Runintointernal static Scan.DescribeImages(..., Action<ImageDescription> store). It now catchesJsonException(non-JSON response),OperationCanceledException(which covers theTaskCanceledExceptionfrom the 10-minuteHttpClient.Timeout),IOExceptionandUnauthorizedAccessException, as well asHttpRequestException. Each failure is logged and collected, and the remaining images carry on.Runpasses astorecallback that keeps the original lock-then-Save()behaviour.Scanends with a "Failed to describe N image(s):" summary listing each failed path and its reason.The optional per-request timeout and retry from the issue are not included; the timeout is now contained rather than fatal.
Test
HashFilesSkipsFilesThatCannotBeReadhashes an existing file together with a missing one. The existing file must be hashed and the missing one dropped.DescribeImagesContinuesPastPerImageFailuresrunsDescribeImagesagainst a localHttpListenerstub of/api/generate. The stub returns an HTML page forbad.jpg, and a third file is deleted before the run.good.jpgmust still be described and stored, and two failures must come back, including theJsonExceptionforbad.jpg.AggregateExceptions the issue reports (FileNotFoundExceptionand'<' is an invalid start of a value). With the fix, the full suite passes 39/39, stable over 5 runs.This branch merges cleanly with #152, #153 and #154.
🤖 Generated with Claude Code
https://claude.ai/code/session_0113g7mUxeizhTrH6na279Ez
Generated by Claude Code