Repository navigation
fix(plugin): guard against non-dict ledger records in accounting and repos - #200
Open
Tejas Lamba (TejasLamba2006) wants to merge 1 commit into
Open
Tejas Lamba (TejasLamba2006) wants to merge 1 commit into
Tejas Lamba (TejasLamba2006) wants to merge 1 commit into
Conversation
…repos store.read_lines can return non-dict JSON values (null, arrays, strings) if a ledger file was corrupted or written incorrectly. Code calling .get() on these records crashes with AttributeError. Added isinstance(r, dict) checks before accessing record fields in: - accounting.summarize (filters at entry) - repos._infer_repo_from_state (inline check) - repos._merge_state (filters ledger lists, inline check for events) Same pattern as the distiller fix in microsoft#199.
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
store.read_linescan return non-dict JSON values (null, arrays, strings) if a ledger file was corrupted or written incorrectly. Code calling.get()on these records crashes withAttributeError.Added
isinstance(r, dict)checks before accessing record fields in:accounting.summarize(filters at entry)repos._infer_repo_from_state(inline check)repos._merge_state(filters ledger lists, inline check for events)Same defensive pattern as the distiller fix in #199.
Test plan
-k "account or repos or ledger")