From 6c6376a823f68bdeb209b6ae45090d70d648ae0d Mon Sep 17 00:00:00 2001 From: Marcin Romaszewicz Date: Tue, 19 May 2026 08:48:59 -0700 Subject: [PATCH] Extend deepObject testing to include unicode Closes #2378 Since we test nearly everything in ASCII, we missed some failures in runtime around marshaling parameters. Extend the deepObject test to catch issues if they resurface. Co-authored-by: Claude Opus 4.7 (1M context) --- examples/go.mod | 2 +- examples/go.sum | 6 +++-- internal/test/go.mod | 2 +- internal/test/go.sum | 4 ++-- .../test/parameters/param_roundtrip_test.go | 23 +++++++++++++++++++ 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/examples/go.mod b/examples/go.mod index 29e5f1b250..2132ce7510 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -21,7 +21,7 @@ require ( github.com/oapi-codegen/iris-middleware v1.0.5 github.com/oapi-codegen/nethttp-middleware v1.1.2 github.com/oapi-codegen/oapi-codegen/v2 v2.0.0-00010101000000-000000000000 - github.com/oapi-codegen/runtime v1.4.0 + github.com/oapi-codegen/runtime v1.4.1 github.com/oapi-codegen/testutil v1.1.0 github.com/stretchr/testify v1.11.1 golang.org/x/lint v0.0.0-20241112194109-818c5a804067 diff --git a/examples/go.sum b/examples/go.sum index 1b42319a6a..b8ab3ad12e 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -215,8 +215,10 @@ github.com/oapi-codegen/iris-middleware v1.0.5 h1:eO33pCvapaf1Xa0esEP0PYcdqPZSeq github.com/oapi-codegen/iris-middleware v1.0.5/go.mod h1:/ysgvbjWyhfDAouIeUOjzIv+zsXfaIXlAQrsOU9/Kyo= github.com/oapi-codegen/nethttp-middleware v1.1.2 h1:TQwEU3WM6ifc7ObBEtiJgbRPaCe513tvJpiMJjypVPA= github.com/oapi-codegen/nethttp-middleware v1.1.2/go.mod h1:5qzjxMSiI8HjLljiOEjvs4RdrWyMPKnExeFS2kr8om4= -github.com/oapi-codegen/runtime v1.4.0 h1:KLOSFOp7UzkbS7Cs1ms6NBEKYr0WmH2wZG0KKbd2er4= -github.com/oapi-codegen/runtime v1.4.0/go.mod h1:5sw5fxCDmnOzKNYmkVNF8d34kyUeejJEY8HNT2WaPec= +github.com/oapi-codegen/nullable v1.1.0 h1:eAh8JVc5430VtYVnq00Hrbpag9PFRGWLjxR1/3KntMs= +github.com/oapi-codegen/nullable v1.1.0/go.mod h1:KUZ3vUzkmEKY90ksAmit2+5juDIhIZhfDl+0PwOQlFY= +github.com/oapi-codegen/runtime v1.4.1 h1:9nwLoI+KrWxzbBcp0jO/R8uXqbik/HUyCvPeU68Y/qo= +github.com/oapi-codegen/runtime v1.4.1/go.mod h1:GwV7hC2hviaMzj+ITfHVRESK5J2W/GefVwIND/bMGvU= github.com/oapi-codegen/testutil v1.1.0 h1:EufqpNg43acR3qzr3ObhXmWg3Sl2kwtRnUN5GYY4d5g= github.com/oapi-codegen/testutil v1.1.0/go.mod h1:ttCaYbHvJtHuiyeBF0tPIX+4uhEPTeizXKx28okijLw= github.com/oasdiff/yaml v0.0.9 h1:zQOvd2UKoozsSsAknnWoDJlSK4lC0mpmjfDsfqNwX48= diff --git a/internal/test/go.mod b/internal/test/go.mod index ef5fde5273..8c270dbbd4 100644 --- a/internal/test/go.mod +++ b/internal/test/go.mod @@ -16,7 +16,7 @@ require ( github.com/labstack/echo/v5 v5.1.0 github.com/oapi-codegen/nullable v1.1.0 github.com/oapi-codegen/oapi-codegen/v2 v2.0.0-00010101000000-000000000000 - github.com/oapi-codegen/runtime v1.4.0 + github.com/oapi-codegen/runtime v1.4.1 github.com/oapi-codegen/testutil v1.1.0 github.com/stretchr/testify v1.11.1 go.yaml.in/yaml/v3 v3.0.4 diff --git a/internal/test/go.sum b/internal/test/go.sum index 2ac681d838..742c531bcf 100644 --- a/internal/test/go.sum +++ b/internal/test/go.sum @@ -191,8 +191,8 @@ github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/oapi-codegen/nullable v1.1.0 h1:eAh8JVc5430VtYVnq00Hrbpag9PFRGWLjxR1/3KntMs= github.com/oapi-codegen/nullable v1.1.0/go.mod h1:KUZ3vUzkmEKY90ksAmit2+5juDIhIZhfDl+0PwOQlFY= -github.com/oapi-codegen/runtime v1.4.0 h1:KLOSFOp7UzkbS7Cs1ms6NBEKYr0WmH2wZG0KKbd2er4= -github.com/oapi-codegen/runtime v1.4.0/go.mod h1:5sw5fxCDmnOzKNYmkVNF8d34kyUeejJEY8HNT2WaPec= +github.com/oapi-codegen/runtime v1.4.1 h1:9nwLoI+KrWxzbBcp0jO/R8uXqbik/HUyCvPeU68Y/qo= +github.com/oapi-codegen/runtime v1.4.1/go.mod h1:GwV7hC2hviaMzj+ITfHVRESK5J2W/GefVwIND/bMGvU= github.com/oapi-codegen/testutil v1.1.0 h1:EufqpNg43acR3qzr3ObhXmWg3Sl2kwtRnUN5GYY4d5g= github.com/oapi-codegen/testutil v1.1.0/go.mod h1:ttCaYbHvJtHuiyeBF0tPIX+4uhEPTeizXKx28okijLw= github.com/oasdiff/yaml v0.0.9 h1:zQOvd2UKoozsSsAknnWoDJlSK4lC0mpmjfDsfqNwX48= diff --git a/internal/test/parameters/param_roundtrip_test.go b/internal/test/parameters/param_roundtrip_test.go index e0b2fc93d1..2bca8801e3 100644 --- a/internal/test/parameters/param_roundtrip_test.go +++ b/internal/test/parameters/param_roundtrip_test.go @@ -392,6 +392,29 @@ func testImpl(t *testing.T, handler http.Handler) { assert.Equal(t, expectedComplexObject, got.DeepObj) }) + // Regression for oapi-codegen/runtime#131: with the v2.7.0 client + // no longer re-encoding query fragments, the runtime marshaller must + // percent-encode reserved URI characters and non-ASCII bytes inside + // deepObject values. Without the fix, '&' splits the value into two + // query params (silent corruption) and non-ASCII bytes produce + // invalid URIs that strict servers reject. + t.Run("deepObject with unicode and reserved chars", func(t *testing.T) { + adversarial := paramclient.ComplexObject{ + Object: paramclient.Object{ + FirstName: "filter&q=こんにちは", + Role: "admin role+with spaces", + }, + Id: 12345, + IsAdmin: true, + } + params := paramclient.GetDeepObjectParams{DeepObj: adversarial} + req, err := paramclient.NewGetDeepObjectRequest(server, ¶ms) + require.NoError(t, err) + var got paramclient.GetDeepObjectParams + doRoundTrip(t, req, &got) + assert.Equal(t, adversarial, got.DeepObj) + }) + t.Run("spaceDelimited", func(t *testing.T) { })