Schema parser requires message attribute blockLength which should be optional
When parsing a schema with message tags that don't specify the blockLength attribute, I get this error:
...
...\lib\site-packages\sbe\__init__.py", line 1088, in _parse_schema
blockLength=int(attrs['blockLength']),
KeyError: 'blockLength'
It looks like the parser depends on this attribute being there, however SBE specifies that blockLength is optional:
<xs:attribute name="blockLength" type="xs:nonNegativeInteger" use="optional">
This is a regression compared to 0.2.8. Bug was introduced in https://github.com/kizzx2/sbe-python/commit/4569d5b945460e07ed0c73ee3c0fdf541db8064d via https://github.com/kizzx2/sbe-python/pull/3 The commit did fix one type of bugs, but introduced another. The issue is _walk_fields_encode should probably return size of the root level message (right now it only returns size of the whole message implicitly via cursor.val), and if blockLength was explicitly set on message type, assert they are equal.
I also came across this issue.
@baryluk do you think it would be correct to set blockLength to zero if it's omitted in schema?
@baryluk @uentity
Thanks very much for the detailed analysis. I am recently not working on FIX on a day-to-day basis so if an example dump can be provided (this library itself can be used to decode + anonymize + encode, hopefully) then it'd be easier for me to try to add some test cases and fix this.