Skip to content

IB export attribute tolerance#4

Merged
vroonhof merged 2 commits intomasterfrom
cursor/ib-export-attribute-tolerance-49a3
Feb 5, 2026
Merged

IB export attribute tolerance#4
vroonhof merged 2 commits intomasterfrom
cursor/ib-export-attribute-tolerance-49a3

Conversation

@vroonhof
Copy link
Owner

@vroonhof vroonhof commented Feb 5, 2026

Add an opt-in mechanism to tolerate unknown XML attributes and element types during parsing to prevent breakage from new Interactive Brokers export fields.

Interactive Brokers frequently introduces new, often irrelevant, fields in their XML exports, which causes ibflex to raise errors like FlexParserError or AttributeError. This PR introduces enable_unknown_attribute_tolerance() and disable_unknown_attribute_tolerance() functions, allowing clients to opt-in to ignoring these unknown fields. These functions are specific to this forked version, ensuring that attempts to use them with the original ibflex package will fail gracefully with an AttributeError, acting as a clear version guard.


Open in Cursor Open in Web

Interactive Brokers frequently adds new fields to their XML exports,
causing parsing failures for attributes/elements not defined in Types.py.

This commit adds an opt-in tolerance mechanism:
- enable_unknown_attribute_tolerance(): silently ignore unknown XML
  attributes and element types during parsing
- disable_unknown_attribute_tolerance(): restore strict behavior (default)

When tolerance is enabled:
- Unknown XML attributes on data elements are filtered out before parsing
- Unknown element types return None and are filtered from containers
- Unknown contained elements in FlexStatement/FlexQueryResponse are skipped
- All known attributes continue to be parsed normally

The functions are exported from the top-level ibflex package. On the
original upstream ibflex package, these functions do not exist, so
calling them raises AttributeError - providing a clear version guard.

Includes 14 new tests covering:
- Default off behavior
- Enable/disable toggling
- Package-level accessibility (version guard)
- Unknown attributes with and without tolerance
- Unknown element types
- Full round-trip parsing with unknown fields
- Container filtering

Co-authored-by: vroonhof <vroonhof@users.noreply.github.com>
@cursor
Copy link

cursor bot commented Feb 5, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

…other data elements

The assertion fires in both strict and tolerant modes. When tolerance
is on, unknown contained elements are filtered out after the assertion.

Co-authored-by: vroonhof <vroonhof@users.noreply.github.com>
@vroonhof vroonhof marked this pull request as ready for review February 5, 2026 21:51
@vroonhof vroonhof merged commit 9bad47c into master Feb 5, 2026
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.

2 participants