Skip to content

fix(pfm): reject fractional retries in forward memo metadata instead of truncating - #9128

Open
HusseinAdeiza wants to merge 1 commit into
lfdt-ibc:mainfrom
HusseinAdeiza:fix/pfm-fractional-retries
Open

HusseinAdeiza wants to merge 1 commit into
lfdt-ibc:mainfrom
HusseinAdeiza:fix/pfm-fractional-retries

Conversation

@HusseinAdeiza

Copy link
Copy Markdown

Fixes #9114

Problem

getForwardMetadata parsed the forward-memo retries field as a JSON float64 and cast it straight to uint8, so a fractional value such as 2.9 was silently truncated to 2 and the packet forwarded with the wrong retry count. Out-of-range values (-1, 256) were already rejected - only the non-integer case slipped through.

Fix

Reject non-integer values with retries must be an integer before the range check:

if retriesFloat != math.Trunc(retriesFloat) {
    return ForwardMetadata{}, errors.New("retries must be an integer")
}

Verification

Added a fractional retries value (2.9) case to the existing TestGetPacketMetadataErrorCases table:

  • red: fails against unpatched code (An error is expected but got nil) - verified via stash/test/restore
  • green: go test ./modules/apps/packet-forward-middleware/... passes with the fix
  • go vet / gofmt clean

@HusseinAdeiza
HusseinAdeiza requested a review from a team as a code owner October 19, 2026 09:24
@greptile-apps

greptile-apps Bot commented Oct 19, 2026

Copy link
Copy Markdown

This PR does not match any of the 1 configured review trigger rule.

@HusseinAdeiza
HusseinAdeiza force-pushed the fix/pfm-fractional-retries branch from 8530b96 to 1736475 Compare October 24, 2026 23:11
…of truncating

`getForwardMetadata` parsed the `retries` field as a JSON float64 and cast it
straight to uint8, so a fractional value like 2.9 was silently truncated to 2
while out-of-range values were already rejected. Treat a non-integer value as
malformed metadata with a clear error, matching the existing range rejection.

Adds a fractional-retries error case to the metadata error-case table; the
test fails against unpatched code (verified by stash-run-restore).

Fixes lfdt-ibc#9114

Signed-off-by: Hussein Adeiza Yunusa <HusseinAdeiza@users.noreply.github.com>
@HusseinAdeiza
HusseinAdeiza force-pushed the fix/pfm-fractional-retries branch from 1736475 to ec390f6 Compare November 23, 2026 02:51
@HusseinAdeiza
HusseinAdeiza requested a review from a team as a code owner November 23, 2026 02:51
@HusseinAdeiza

Copy link
Copy Markdown
Author

Rebased onto main. go test ./modules/apps/packet-forward-middleware/... passes (the fractional retries case now errors instead of truncating).

This branch has not been deployed

No deployments
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.

[PFM] packet-forward middleware silently truncates fractional retries instead of rejecting it

1 participant