Skip to content

fix(plugin): guard against non-dict ledger records in accounting and repos - #200

Open
Tejas Lamba (TejasLamba2006) wants to merge 1 commit into
microsoft:mainfrom
TejasLamba2006:fix/isinstance-ledger-records
Open

Tejas Lamba (TejasLamba2006) wants to merge 1 commit into
microsoft:mainfrom
TejasLamba2006:fix/isinstance-ledger-records

Conversation

@TejasLamba2006

Copy link
Copy Markdown
Contributor

Summary

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 defensive pattern as the distiller fix in #199.

Test plan

  • Related tests pass (-k "account or repos or ledger")
  • Syntax check passes

…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.
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.

1 participant