Skip to content

fix: prevent crash when distribution summary empty#105

Merged
MicBun merged 1 commit intomainfrom
preventCrashonNull
Feb 27, 2026
Merged

fix: prevent crash when distribution summary empty#105
MicBun merged 1 commit intomainfrom
preventCrashonNull

Conversation

@MicBun
Copy link
Member

@MicBun MicBun commented Feb 27, 2026

resolves: #102

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced error handling for distribution summary queries to return gracefully when no results are found, instead of raising an error.
    • Improved null-safety handling in API responses.

@MicBun MicBun self-assigned this Feb 27, 2026
@holdex
Copy link

holdex bot commented Feb 27, 2026

Time Submission Status

Member Status Time Action Last Update
MicBun ✅ Submitted 4h Update time Feb 27, 2026, 11:46 AM

You can submit time with the command. Example:

@holdex pr submit-time 15m

See available commands to help comply with our Guidelines.

@holdex
Copy link

holdex bot commented Feb 27, 2026

Bug Report Checklist

Status Commit Link Bug Author HR Card
✅ Submitted commit link @MicBun HR Card

If this commit or author is incorrect, reply in this PR with:

@holdex bug dispute <correct-commit-url> && bug author @correct-user

Use git blame to identify the right commit and author before posting.

See available commands to help comply with our Guidelines.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

The pull request addresses a crash in get_distribution_summary by adding nil-safety checks in the Go bindings layer and updating the Python SDK public API to return Optional[DistributionSummary], returning None when no distribution result is found instead of raising an error.

Changes

Cohort / File(s) Summary
Go Bindings
bindings/bindings.go
Added nil-safety check in GetDistributionSummary to handle missing distribution results gracefully by returning an empty string without error.
Python SDK
src/trufnetwork_sdk_py/client.py
Updated get_distribution_summary method signature to return Optional[DistributionSummary]; now returns None instead of raising RuntimeError when no distribution result is available. Added Optional import.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A crash in the distribution, oh what a fright!
But now we return None, so graceful and right—
No errors that thunder, just silence so sweet,
When queries find nothing, the SDK's still neat! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The PR addresses objective (a) from issue #102 by preventing crashes when distribution summaries are nil. However, objective (b) regarding get_participant_reward_history returning empty lists is not addressed by these changes. Clarify whether this PR fully resolves issue #102 or if objective (b) requires separate changes. The current changes only address the nil crash handling, not the empty reward history problem.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Out of Scope Changes check ✅ Passed All changes are directly related to handling nil distribution summaries across both Go and Python implementations, staying within the scope of issue #102 objective (a).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title accurately describes the main change: adding nil-safety checks to prevent crashes when distribution summary is empty, which is the core fix across both the Go bindings and Python client.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch preventCrashonNull

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MicBun
Copy link
Member Author

MicBun commented Feb 27, 2026

@holdex bug commit fbc3020 && bug author @MicBun

@MicBun MicBun changed the title fix: prevent crash when distribution summary return nil fix: prevent crash when distribution summary empty Feb 27, 2026
@MicBun MicBun merged commit 7d91f7d into main Feb 27, 2026
7 checks passed
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.

Problem: LP rewards not flowing on testnet

1 participant