Skip to content

transport/http/jsonrpc: preserve numeric request IDs without rounding - #1316

Open
tianrking wants to merge 1 commit into
go-kit:masterfrom
tianrking:codex/jsonrpc-id-precision
Open

tianrking wants to merge 1 commit into
go-kit:masterfrom
tianrking:codex/jsonrpc-id-precision

Conversation

@tianrking

Copy link
Copy Markdown

Numeric JSON-RPC request IDs can change when echoed in a response. If an ID cannot be decoded as an int, RequestID.MarshalJSON falls back to float32: for example, 18446744073709551615 becomes 18446744000000000000, and 9007199254740993e0 becomes 9007199000000000. Numbers outside the float32 range can become an empty string or zero. This breaks the JSON-RPC requirement to return the same ID value.

Keep a private json.Number representation for encoding numeric IDs. The existing Int, Float32, and String conversions and zero-value behavior remain available. Regression tests cover large integers, decimal and exponent forms, accessor limits, reused IDs and input buffers, and actual HTTP success and error responses through each endpoint codec stage.

Validation on source commit 09229de947a8459b72fffc8f1e7387503617a9f8:

  • Unchanged-production RED: actual go test exit 1, with 27 failing leaf cases and 18 passing controls. The workflow succeeds only because it explicitly expects RED. The test file is byte-identical to this PR.
  • Final native matrix: Go 1.17.13, 1.18.10, and 1.19.13 each pass the regression tests and the original full -race -covermode=atomic -tags integration ./... suite with GOFLAGS=-mod=readonly. Each version has 280 top-level passes and the same five existing skips. JSON-RPC package vet and formatting checks pass.
  • The whole-repository vet and formatting checks still fail. Unchanged baseline quality has identical vet diagnostics and identical formatting file lists for each Go version. These existing failures are retained, and the final workflow is marked failure, not an all-checks-green result.

The original Eureka image uses Docker schema 1, so its default pull fails on the hosted runner's Docker 28.0.4. The environment proof records that failure, verifies the compatibility flag in the exact daemon version's source, and enables it only in the isolated runner. Baseline and final jobs use the same daemon binary and original pinned image digests, with real etcd, Consul, ZooKeeper, and Eureka readiness checks. This is a disclosed compatible environment, not proof that the default upstream CI environment succeeds. No dependency, CI, or service-image change is included in the PR.

Complete tracked-source HEAD, Git blob, SHA-256, and cleanliness snapshots are uploaded before and after native commands. Implementation and testing were assisted by AI; the change and native evidence were reviewed before submission.

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