Update _strip_str to remove null characters#703
Conversation
Modify _strip_str method to remove null characters.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR updates the CMIS transceiver API string sanitization so that EEPROM-decoded strings containing embedded NUL (\x00) characters are cleaned up before being returned, addressing cases where downstream consumers (e.g., SNMP-related tests) only see a truncated prefix.
Changes:
- Extend
CmisApi._strip_str()to remove embedded\x00characters before trimming trailing whitespace.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@wenyiz2021 Isn't this a module issue wherein the vendor has not padded spaces and has instead used null character?
|
thanks @mihirpat1 for bringing up, not sure, I've also asked vendor to check thihs PR but they havn't replied. looks like just that string issue on dut. |
|
looks like wrong cable transceiver info |
|
We believe this is a 1-off issue with a XCVR, we shouldn't try to handle this in S/W |


Modify _strip_str method to remove null characters.
e.g.sudo redis-cli -n 6 HGET 'TRANSCEIVER_INFO|Ethernet0' manufacturer | xxd | head -5;
The redis value stored is:
41 00 00 00 00 00 4e 65 74 77 6f 72 6b 73
A \0 \0 \0 \0 \0 N e t w o r k s
this is causing test_snmp_phy_entity to fail because of failing to parse the \0 above.
the failure was only seen on one of the DUT
which had
so failing to strip the \0 is causing ssnmp agent returns just A
on another DUT it is fine because of not having \0:
Description
Motivation and Context
How Has This Been Tested?
applied the fix on dut directly and restarted xcvrd:
in /usr/local/lib/python3.11/dist-packages/sonic_platform_base/sonic_xcvr/api/public/cmis.py
Before: 41 00 00 00 00 00 4e 65 74 77 6f 72 6b 73 → A\x00\x00\x00\x00\x00Networks
After: 41 4e 65 74 77 6f 72 6b 73 → ANetworks
Additional Information (Optional)