Skip to content

DP-1.14: fix potential nil pointer dereference errors#5363

Open
karthikeya-remilla wants to merge 4 commits intoopenconfig:mainfrom
b4firex:karremil/dp-1.14-panic-fix
Open

DP-1.14: fix potential nil pointer dereference errors#5363
karthikeya-remilla wants to merge 4 commits intoopenconfig:mainfrom
b4firex:karremil/dp-1.14-panic-fix

Conversation

@karthikeya-remilla
Copy link
Copy Markdown
Contributor

In instances where the telemetry values are not received, code still goes on to check related data causing panic and test abortion. This diff plans to handle errors gracefully.

qos_basic_test.go:445: TransmitPkts count for queue "TenGigE0/0/0/0/2" on interface "AF3" not available within 1m0s
   --- FAIL: TestBasicConfigWithTraffic/Non-oversubscription_80_percent_of_linerate_traffic (69.51s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
   panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10a797fb4]

goroutine 12 [running]:
testing.tRunner.func1.2({0x10c028260, 0x117fe7980})
   /Users/karremil/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.7.darwin-arm64/src/testing/testing.go:1734 +0x1ac
testing.tRunner.func1()
   /Users/karremil/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.7.darwin-arm64/src/testing/testing.go:1737 +0x334
panic({0x10c028260?, 0x117fe7980?})
   /Users/karremil/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.7.darwin-arm64/src/runtime/panic.go:792 +0x124
github.com/openconfig/ygnmi/ygnmi.(*Value[...]).Val(...)
   /Users/karremil/go/pkg/mod/github.com/openconfig/ygnmi@v0.14.0/ygnmi/ygnmi.go:126
github.com/openconfig/featureprofiles/feature/qos/otg_tests/qos_basic_test_test.TestBasicConfigWithTraffic.func1(0x14000503c00)
   /Users/karremil/GolandProjects/b4firex/featureprofiles/feature/qos/otg_tests/qos_basic_test/qos_basic_test.go:447 +0xa94
testing.tRunner(0x14000503c00, 0x14007e84060)
   /Users/karremil/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.7.darwin-arm64/src/testing/testing.go:1792 +0xe4
created by testing.(*T).Run in goroutine 72
   /Users/karremil/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.7.darwin-arm64/src/testing/testing.go:1851 +0x374

@karthikeya-remilla karthikeya-remilla requested a review from a team as a code owner April 20, 2026 10:03
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a stability issue in the QoS basic test suite where missing telemetry data caused nil pointer dereference panics. By implementing proper validation checks before accessing the returned values, the tests now handle missing data gracefully without aborting execution.

Highlights

  • Error Handling: Added nil checks for telemetry values returned by gnmi.Watch to prevent runtime panics when data is missing.
  • Control Flow: Updated logic to only attempt to access telemetry values if the watch operation is successful and the result is non-nil.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@OpenConfigBot
Copy link
Copy Markdown

OpenConfigBot commented Apr 20, 2026

Pull Request Functional Test Report for #5363 / d86deda

Virtual Devices

Device Test Test Documentation Job Raw Log
Arista cEOS status
DP-1.14: QoS basic test
Cisco 8000E status
DP-1.14: QoS basic test
Cisco XRd status
DP-1.14: QoS basic test
Juniper ncPTX status
DP-1.14: QoS basic test
Nokia SR Linux status
DP-1.14: QoS basic test
Openconfig Lemming status
DP-1.14: QoS basic test

Hardware Devices

Device Test Test Documentation Raw Log
Arista 7808 status
DP-1.14: QoS basic test
Cisco 8808 status
DP-1.14: QoS basic test
Juniper PTX10008 status
DP-1.14: QoS basic test
Nokia 7250 IXR-10e status
DP-1.14: QoS basic test

Help

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the QoS basic test by adding null checks for counter values and correcting the argument order in error messages. The review feedback suggests using t.Fatalf instead of t.Errorf for these critical counter retrievals to ensure the test fails fast if baseline data is unavailable. Furthermore, the reviewer noted that the explicit count == nil checks are redundant because the ok return value from Await(t) already guarantees the presence of a non-nil value.

Comment thread feature/qos/otg_tests/qos_basic_test/qos_basic_test.go Outdated
Comment thread feature/qos/otg_tests/qos_basic_test/qos_basic_test.go Outdated
Comment thread feature/qos/otg_tests/qos_basic_test/qos_basic_test.go Outdated
Comment thread feature/qos/otg_tests/qos_basic_test/qos_basic_test.go Outdated
@AmrNJ AmrNJ self-assigned this Apr 27, 2026
@karthikeya-remilla
Copy link
Copy Markdown
Contributor Author

@AmrNJ please help in getting this merged by requesting internal reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants