Fix Handle non-responsive SFP modules gracefully in sfputil#4654
Open
nhilderm-ciena wants to merge 1 commit into
Open
Fix Handle non-responsive SFP modules gracefully in sfputil#4654nhilderm-ciena wants to merge 1 commit into
nhilderm-ciena wants to merge 1 commit into
Conversation
|
|
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
6 tasks
Add None guards in sfputil show eeprom and show fwversion commands to prevent crashes when transceiver modules are non-responsive or return None from platform API calls. sfputil commands crash on non-responsive SFP modules. When an SFP module is physically present but non-responsive (e.g. due to I2C timeout), the platform API calls get_transceiver_info() and get_xcvr_api() return None. The existing code does not check for None before attempting to use the return values, causing unhandled exceptions. The Problem: In sfputil show eeprom, get_transceiver_info() returns None for a non-responsive module but the code immediately passes the result to convert_sfp_info_to_output_string(), which crashes. In sfputil show fwversion, get_xcvr_api() returns None but the code immediately calls api.get_module_fw_info(), which crashes with AttributeError. Added explicit None checks: - In eeprom command: check xcvr_info before processing, print error and continue to next port if None - In fwversion command: check api before calling get_module_fw_info(), print error and exit gracefully if None - Test with a non-responsive SFP module present: sfputil show eeprom -p EthernetX (should print error message instead of crashing) - Test firmware version with non-responsive module: sfputil show fwversion -p EthernetX (should print error message instead of crashing) - Test with responsive modules (regression): sfputil show eeprom sfputil show fwversion -p EthernetX (should work normally) Signed-off-by: nhilderm <nhilderm@ciena.com>
nhilderm-ciena
force-pushed
the
fix/sfputil-handle-non-responsive-modules
branch
from
June 30, 2026 13:46
61f3823 to
4fd1682
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
nhilderm-ciena
force-pushed
the
fix/sfputil-handle-non-responsive-modules
branch
from
June 30, 2026 14:47
ddbd82c to
aa530bf
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
nhilderm-ciena
force-pushed
the
fix/sfputil-handle-non-responsive-modules
branch
from
June 30, 2026 15:13
aa530bf to
4fd1682
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
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.
Handle non-responsive SFP modules gracefully in sfputil show eeprom and show fwversion commands.
What I did
Added None guards in sfputil show eeprom and show fwversion commands to prevent crashes when transceiver modules are non-responsive or return None from platform API calls.
When an SFP module is physically present but non-responsive (e.g. due to I2C timeout), the platform API calls
get_transceiver_info()andget_xcvr_api()return None. The existing code does not check for None before attempting to use the return values, causing unhandled exceptions.The Problem:
sfputil show eeprom,get_transceiver_info()returns None for a non-responsive module but the code immediately passes the result toconvert_sfp_info_to_output_string(), which crashes.sfputil show fwversion,get_xcvr_api()returns None but the code immediately callsapi.get_module_fw_info(), which crashes with AttributeError.How I did it
Added explicit None checks:
xcvr_infobefore processing, print error and continue to next port if Noneapibefore callingget_module_fw_info(), print error and exit gracefully if NoneHow to verify it
Test with a non-responsive SFP module present:
sfputil show eeprom -p EthernetX(should print error message instead of crashing)
Test firmware version with non-responsive module:
sfputil show fwversion -p EthernetX(should print error message instead of crashing)
Test with responsive modules (regression):
sfputil show eepromsfputil show fwversion -p EthernetX(should work normally)
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)