sbe-python icon indicating copy to clipboard operation
sbe-python copied to clipboard

Schema parser requires message attribute blockLength which should be optional

Open harenbrs opened this issue 3 years ago • 3 comments

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">

harenbrs avatar Oct 03 '22 19:10 harenbrs

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.

baryluk avatar Jun 02 '23 13:06 baryluk

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?

uentity avatar Jul 08 '24 10:07 uentity

@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.

kizzx2 avatar Jul 08 '24 13:07 kizzx2