Skip to content

export_transactions CSV crashes on "Aktien erhalten" event #350

@MarineThierry

Description

@MarineThierry

Bug: export_transactions CSV crashes on "Aktien erhalten" event

Description

Running pytr export_transactions with CSV format crashes with an AttributeError when the timeline contains an "Aktien erhalten" (shares received) event. JSON export works fine.

Steps to reproduce

pytr export_transactions

Expected behavior

CSV file is exported, unknown event types are skipped or handled gracefully.

Actual behavior

The command crashes with the following traceback:

21:44:23 Ignoring unknown event "AI & Big Data USD (Acc) Aktien erhalten (9e81acd0-3fe1-409b-abfd-96f26088eeb0)"
Traceback (most recent call last):
  File ".../bin/pytr", line 12, in <module>
    sys.exit(main())
  File ".../pytr/main.py", line 533, in main
    [Event.from_dict(item) for item in events],
  File ".../pytr/event.py", line 462, in from_dict
    note = cls._parse_card_note(event_dict)
  File ".../pytr/event.py", line 790, in _parse_card_note
    if eventTypeStr.startswith("card_"):
       ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'startswith'

Root cause (hypothesis)

_parse_card_note in event.py (line 790) calls .startswith() on eventTypeStr without checking if it's None first. The "Aktien erhalten" event type seems to return None for this field.

Environment

  • OS: Linux
  • pytr version: latest
  • Login method: web login

Workaround

JSON export works fine. The data can be converted to CSV manually via pandas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions