Skip to content

cmd/devp2p/ethtest: fix swapped args in private-key error message#35193

Open
ozpool wants to merge 1 commit into
ethereum:masterfrom
ozpool:fix/ethtest-privkey-error-args
Open

cmd/devp2p/ethtest: fix swapped args in private-key error message#35193
ozpool wants to merge 1 commit into
ethereum:masterfrom
ozpool:fix/ethtest-privkey-error-args

Conversation

@ozpool

@ozpool ozpool commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

While reading the ethtest sender-loading path I noticed the error for a failed key decode passes its arguments in the wrong order:

pk, err := crypto.HexToECDSA(common.Bytes2Hex(acc.Key))
if err != nil {
    return nil, fmt.Errorf("unable to read private key for %s: %v", err, addr)
}

The format string is for %s: %v (address, then reason), but the arguments are (err, addr). So the message prints the decode error where the account address should be and the address where the reason should be, e.g.:

unable to read private key for invalid hex character 'x' in private key: 0xAbC...

Swapping to (addr, err) makes it read as intended:

unable to read private key for 0xAbC...: invalid hex character 'x' in private key

go build ./cmd/devp2p/... and go vet ./cmd/devp2p/internal/ethtest/ pass.

The error "unable to read private key for %s: %v" passed (err, addr),
so it printed the decode error where the account address belongs and the
address where the error belongs. Swap to (addr, err) so the message names
the account that failed and then the reason.
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.

1 participant