binance / binance/binance-fix-connector-python

[BUG] FIX Message parsing fails with 'ValueError: Field missing '=' separator.'

Open
#7 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
14
Forks
12
PR merge metrics
No merged PRs in 30d

Description

### Problem / Bug Description

When streaming market data, the `binance-fix-connector-python` library fails to parse messages occasionally with a `ValueError: Field missing '=' separator.`.

The traceback shows the error occurs during string appending in `simplefix` when an invalid (likely empty or delimiter-only) tag is passed for parsing:

ValueError: Field missing '=' separator.
Traceback (most recent call last):
File "/.../fix_connector.py", line 444, in __receive_messages
messages = self.parse_server_response()
File "/.../fix_connector.py", line 396, in parse_server_response
fix_msg.append_strings(tag_values)
File "/.../simplefix/message.py", line 444, in append_string
raise ValueError("Field missing '=' separator.")

### Logs Example (from a failed run)

*(يمكنك نسخ أجزاء من سجلات `INFO` و `ERROR` التي أرسلتها في بداية المشكلة)*

### Solution / Workaround

The issue is solved by making the tag validation stricter in `FixConnector.parse_server_response()` to filter out all invalid strings before passing them to `simplefix`.

**Proposed change in `fix_connector.py` (around line 401):**

Change from:
```python
tag_values = [x for x in raw_messages[i].split(_SOH_) if x != ""]

To:

tag_values = [x for x in raw_messages[i].split(_SOH_) if "=" in x]

Additionally, a small try/except was needed in __receive_messages to handle logging for partially received messages without a proper MsgType:

# In __receive_messages (around line 448)
for msg in messages:
try:
clean_message = msg.encode().decode("utf-8").replace(_SOH_, "|")
except ValueError:
self.logger.warning("Message decoded but could not be logged (missing MsgType: 35)")
continue

self.logger.info(
"%sServer=>Client: %s%s", GREEN, clean_message, RESET
)

This change fully resolves the streaming stability issue on a local installation.

[fix_connector.py](https://github.com/user-attachments/files/23567920/fix_connector.py)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.