Skip to content

fix: verify dogT exists in the context before using it#692

Merged
vearutop merged 1 commit intocucumber:mainfrom
cakoolen:patch-1
Jul 15, 2025
Merged

fix: verify dogT exists in the context before using it#692
vearutop merged 1 commit intocucumber:mainfrom
cakoolen:patch-1

Conversation

@cakoolen
Copy link
Copy Markdown
Contributor

getTestingT(ctx) can return a nil pointer (if there is no dogT in the context) in this case a segfault causes the whole test harness to fail. By verifying whether there is a dogT in the context, the test can continue.

🤔 What's changed?

Added a check to verify whether the dogT was available in the context before querying its state.

⚡️ What's your motivation?

While using godog (After updating from v0.12.x to v0.15.0) our test harness ran into a segfault. The cause of the segfault was a nil pointer deference that is verified to be fixed with the proposed change.

🏷️ What kind of change is this?

  • 🐛 Bug fix (non-breaking change which fixes a defect)

📋 Checklist:


This text was originally generated from a template, then edited by hand. You can modify the template here.

getTestingT(ctx) can return a nil pointer (if there is no dogT in the context) in this case a segfault causes the whole test harness to fail. By verifying whether there is a dogT in the context, the test can continue.
@codecov
Copy link
Copy Markdown

codecov bot commented Jul 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.88%. Comparing base (153db4e) to head (c93946a).
Report is 31 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #692      +/-   ##
==========================================
- Coverage   83.21%   77.88%   -5.33%     
==========================================
  Files          28       41      +13     
  Lines        3413     4051     +638     
==========================================
+ Hits         2840     3155     +315     
- Misses        458      778     +320     
- Partials      115      118       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vearutop vearutop merged commit 3651f88 into cucumber:main Jul 15, 2025
6 of 7 checks passed
@cakoolen
Copy link
Copy Markdown
Contributor Author

Is there any release scheduled for this module? Currently we are using a fork to work around this issue but I would prefer to switch back to the main project once there is a release with this fix in it.

@vearutop
Copy link
Copy Markdown
Member

New version https://github.com/cucumber/godog/releases/tag/v0.15.1 released with this and a few other changes. Thank you for contribution!

@cakoolen
Copy link
Copy Markdown
Contributor Author

Thank you for merging it so quick and create the release!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants