Merged
Conversation
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 Agent can help with this pull request. Just |
…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>
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.
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
ibflexto raise errors likeFlexParserErrororAttributeError. This PR introducesenable_unknown_attribute_tolerance()anddisable_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 originalibflexpackage will fail gracefully with anAttributeError, acting as a clear version guard.