Skip to content

fix: coerce null eventType to empty string in _parse_card_note (#350)#351

Open
SAY-5 wants to merge 3 commits into
pytr-org:masterfrom
SAY-5:say5-fix-null-event-type
Open

fix: coerce null eventType to empty string in _parse_card_note (#350)#351
SAY-5 wants to merge 3 commits into
pytr-org:masterfrom
SAY-5:say5-fix-null-event-type

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 11, 2026

Closes #350.

_parse_card_note reads event_dict.get("eventType", ""), but dict.get(k, default) only returns the default when the key is absent. The Trade Republic timeline includes "Aktien erhalten" (shares-received) entries where the key is present with value null, so eventTypeStr becomes None and the next line's eventTypeStr.startswith("card_") nil-derefs, breaking pytr export_transactions CSV export end-to-end.

Replaces the default with event_dict.get("eventType") or "" so both missing and null collapse to an empty string. Regression test test_parse_card_note_returns_none_when_event_type_is_null covers the null case (the bug repro), the existing absent case, and the existing card_-prefix happy path.

@RealCLanger
Copy link
Copy Markdown
Collaborator

Good catch. Could you maybe add a full test for an "Aktien erhalten" event?

@SAY-5
Copy link
Copy Markdown
Author

SAY-5 commented May 12, 2026

Sure. I don't have a real 'Aktien erhalten' payload handy. From #350's traceback it looks like the original event had eventType=null and the title 'AI & Big Data USD (Acc) Aktien erhalten'. Do you have a sanitized fixture I can drop into tests/aktien_erhalten*.json, or is the existing aktiensplit_no_eventType.json (which already carries the 'Du hast Aktien aus einer Kapitalmaßnahme erhalten' header) close enough to repurpose?

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.

export_transactions CSV crashes on "Aktien erhalten" event

2 participants