fix(viewer): skip unreadable/non-UTF-8 files instead of aborting the whole bundle#122
Open
mftnakrsu wants to merge 1 commit into
Open
Conversation
…whole bundle _walk_concepts caught only OKFDocumentError, so a single file with invalid UTF-8 bytes, a read error, or a bare ValueError from PyYAML (e.g. an out-of-range timestamp) aborted the entire visualize run. Broaden the handler to (ValueError, OSError) and skip the offending file, matching the tolerance bundle.index._load_doc already applies. Adds tests for the invalid-UTF-8 and bad-timestamp cases.
cf975be to
c97c1ae
Compare
Author
|
@amirhormati a small viewer robustness fix — skip unreadable/non-UTF-8 files instead of aborting the whole visualize run. Rebased onto the latest |
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.
What
enrichment_agent visualizeaborts the entire bundle if a single concept file can't be read, decoded, or parsed.Why
In
viewer/generator.py,_walk_conceptsreads every concept withread_text(encoding="utf-8")and parses it, but only caughtOKFDocumentError. Three realistic failure modes still escaped and killed the wholevisualizecommand:UnicodeDecodeErrorOSErrortimestamp: 2026-13-45— makes PyYAML's implicit resolver raise a bareValueErrorthatOKFDocument.parsedoes not wrapOne bad file takes down the whole graph. The sibling
bundle/index.py::_load_docalready tolerates all of these (except Exception: return None).Change
(ValueError, OSError).ValueErrorsubsumesOKFDocumentErrorandUnicodeDecodeError(both subclasses) as well as PyYAML's bareValueError;OSErrorcovers read errors. The now-unusedOKFDocumentErrorimport is dropped.test_unreadable_concept_file_is_skipped(invalid UTF-8) andtest_malformed_timestamp_concept_file_is_skipped(bad timestamp → bareValueError), each asserting the remaining concepts still render.Tests:
pytest okf/tests/test_viewer.py→ 8 passed.🤖 Generated with Claude Code