Skip to content

Fix signer_nonce serialization in ContractFunctionResult#2293

Merged
manishdait merged 2 commits into
hiero-ledger:mainfrom
utkarsh232005:fix-signer-nonce-serialization-bug
May 18, 2026
Merged

Fix signer_nonce serialization in ContractFunctionResult#2293
manishdait merged 2 commits into
hiero-ledger:mainfrom
utkarsh232005:fix-signer-nonce-serialization-bug

Conversation

@utkarsh232005

Copy link
Copy Markdown
Contributor

This PR fixes a serialization bug in ContractFunctionResult._to_proto() and adds corresponding unit test coverage. Fixes #2251

Signed-off-by: utkarsh patrikar <utkarshpatrikar@gmail.com>
Copilot AI review requested due to automatic review settings May 16, 2026 16:11
@utkarsh232005
utkarsh232005 requested review from a team as code owners May 16, 2026 16:11
@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f6cf3dc2-e568-42dc-b4e5-e65d43780f30

📥 Commits

Reviewing files that changed from the base of the PR and between 679e4a6 and d97a747.

📒 Files selected for processing (2)
  • src/hiero_sdk_python/contract/contract_function_result.py
  • tests/unit/contract_function_result_test.py

Walkthrough

ContractFunctionResult._to_proto() now conditionally wraps signer_nonce in Int64Value only when not None, preventing silent conversion of absent nonce to zero. A unit test validates both absent and zero cases.

Changes

signer_nonce Optional Field Serialization

Layer / File(s) Summary
Conditional signer_nonce Int64Value wrapping
src/hiero_sdk_python/contract/contract_function_result.py, tests/unit/contract_function_result_test.py
_to_proto() now conditionally wraps signer_nonce in Int64Value only when self.signer_nonce is not None, preventing the protobuf field from silently defaulting to zero when absent. Test verifies field presence via HasField() when None and confirms encoded value when set to 0.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix signer_nonce serialization in ContractFunctionResult' clearly and specifically summarizes the main change—fixing a serialization bug in the signer_nonce handling.
Description check ✅ Passed The description accurately relates to the changeset, explaining the serialization bug fix and referencing the linked issue #2251.
Linked Issues check ✅ Passed The PR fully addresses all coding requirements from issue #2251: conditionally wraps signer_nonce in Int64Value only when not None, adds unit test coverage for the None case, and preserves the distinction between signer_nonce=0 and omitted field.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the signer_nonce serialization bug identified in issue #2251—no extraneous modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #2251

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review python Pull requests that update python code skill: beginner Achievable by a fairly new comer that has already completed a couple of good first issues labels May 16, 2026
@codecov

codecov Bot commented May 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2293   +/-   ##
=======================================
  Coverage   93.97%   93.97%           
=======================================
  Files         163      163           
  Lines       10408    10408           
=======================================
  Hits         9781     9781           
  Misses        627      627           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Dosik13 Dosik13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@manishdait

Copy link
Copy Markdown
Contributor

@utkarsh232005, Please update the branch

@AntonioCeppellini AntonioCeppellini left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 🛩️ :D
thank you for your contribution!

@manishdait
manishdait merged commit 47ecff2 into hiero-ledger:main May 18, 2026
28 checks passed
@github-actions

Copy link
Copy Markdown

@utkarsh232005
utkarsh232005 deleted the fix-signer-nonce-serialization-bug branch May 18, 2026 09:45
@manishdait manishdait added this to the v0.2.7 milestone May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open to community review PR is open for community review and feedback python Pull requests that update python code queue:junior-committer PR awaiting initial quality review skill: beginner Achievable by a fairly new comer that has already completed a couple of good first issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ContractFunctionResult._to_proto() silently sends signer_nonce=0 when it should be omitted

5 participants