Skip to content

Commit 8c4029a

Browse files
mromaszewiczclaude
andauthored
Extend deepObject testing to include unicode (#2381)
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) <noreply@anthropic.com>
1 parent 84bfb1b commit 8c4029a

5 files changed

Lines changed: 31 additions & 6 deletions

File tree

examples/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require (
2121
github.com/oapi-codegen/iris-middleware v1.0.5
2222
github.com/oapi-codegen/nethttp-middleware v1.1.2
2323
github.com/oapi-codegen/oapi-codegen/v2 v2.0.0-00010101000000-000000000000
24-
github.com/oapi-codegen/runtime v1.4.0
24+
github.com/oapi-codegen/runtime v1.4.1
2525
github.com/oapi-codegen/testutil v1.1.0
2626
github.com/stretchr/testify v1.11.1
2727
golang.org/x/lint v0.0.0-20241112194109-818c5a804067

examples/go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ github.com/oapi-codegen/iris-middleware v1.0.5 h1:eO33pCvapaf1Xa0esEP0PYcdqPZSeq
215215
github.com/oapi-codegen/iris-middleware v1.0.5/go.mod h1:/ysgvbjWyhfDAouIeUOjzIv+zsXfaIXlAQrsOU9/Kyo=
216216
github.com/oapi-codegen/nethttp-middleware v1.1.2 h1:TQwEU3WM6ifc7ObBEtiJgbRPaCe513tvJpiMJjypVPA=
217217
github.com/oapi-codegen/nethttp-middleware v1.1.2/go.mod h1:5qzjxMSiI8HjLljiOEjvs4RdrWyMPKnExeFS2kr8om4=
218-
github.com/oapi-codegen/runtime v1.4.0 h1:KLOSFOp7UzkbS7Cs1ms6NBEKYr0WmH2wZG0KKbd2er4=
219-
github.com/oapi-codegen/runtime v1.4.0/go.mod h1:5sw5fxCDmnOzKNYmkVNF8d34kyUeejJEY8HNT2WaPec=
218+
github.com/oapi-codegen/nullable v1.1.0 h1:eAh8JVc5430VtYVnq00Hrbpag9PFRGWLjxR1/3KntMs=
219+
github.com/oapi-codegen/nullable v1.1.0/go.mod h1:KUZ3vUzkmEKY90ksAmit2+5juDIhIZhfDl+0PwOQlFY=
220+
github.com/oapi-codegen/runtime v1.4.1 h1:9nwLoI+KrWxzbBcp0jO/R8uXqbik/HUyCvPeU68Y/qo=
221+
github.com/oapi-codegen/runtime v1.4.1/go.mod h1:GwV7hC2hviaMzj+ITfHVRESK5J2W/GefVwIND/bMGvU=
220222
github.com/oapi-codegen/testutil v1.1.0 h1:EufqpNg43acR3qzr3ObhXmWg3Sl2kwtRnUN5GYY4d5g=
221223
github.com/oapi-codegen/testutil v1.1.0/go.mod h1:ttCaYbHvJtHuiyeBF0tPIX+4uhEPTeizXKx28okijLw=
222224
github.com/oasdiff/yaml v0.0.9 h1:zQOvd2UKoozsSsAknnWoDJlSK4lC0mpmjfDsfqNwX48=

internal/test/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/labstack/echo/v5 v5.1.0
1717
github.com/oapi-codegen/nullable v1.1.0
1818
github.com/oapi-codegen/oapi-codegen/v2 v2.0.0-00010101000000-000000000000
19-
github.com/oapi-codegen/runtime v1.4.0
19+
github.com/oapi-codegen/runtime v1.4.1
2020
github.com/oapi-codegen/testutil v1.1.0
2121
github.com/stretchr/testify v1.11.1
2222
go.yaml.in/yaml/v3 v3.0.4

internal/test/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
191191
github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc=
192192
github.com/oapi-codegen/nullable v1.1.0 h1:eAh8JVc5430VtYVnq00Hrbpag9PFRGWLjxR1/3KntMs=
193193
github.com/oapi-codegen/nullable v1.1.0/go.mod h1:KUZ3vUzkmEKY90ksAmit2+5juDIhIZhfDl+0PwOQlFY=
194-
github.com/oapi-codegen/runtime v1.4.0 h1:KLOSFOp7UzkbS7Cs1ms6NBEKYr0WmH2wZG0KKbd2er4=
195-
github.com/oapi-codegen/runtime v1.4.0/go.mod h1:5sw5fxCDmnOzKNYmkVNF8d34kyUeejJEY8HNT2WaPec=
194+
github.com/oapi-codegen/runtime v1.4.1 h1:9nwLoI+KrWxzbBcp0jO/R8uXqbik/HUyCvPeU68Y/qo=
195+
github.com/oapi-codegen/runtime v1.4.1/go.mod h1:GwV7hC2hviaMzj+ITfHVRESK5J2W/GefVwIND/bMGvU=
196196
github.com/oapi-codegen/testutil v1.1.0 h1:EufqpNg43acR3qzr3ObhXmWg3Sl2kwtRnUN5GYY4d5g=
197197
github.com/oapi-codegen/testutil v1.1.0/go.mod h1:ttCaYbHvJtHuiyeBF0tPIX+4uhEPTeizXKx28okijLw=
198198
github.com/oasdiff/yaml v0.0.9 h1:zQOvd2UKoozsSsAknnWoDJlSK4lC0mpmjfDsfqNwX48=

internal/test/parameters/param_roundtrip_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,29 @@ func testImpl(t *testing.T, handler http.Handler) {
392392
assert.Equal(t, expectedComplexObject, got.DeepObj)
393393
})
394394

395+
// Regression for oapi-codegen/runtime#131: with the v2.7.0 client
396+
// no longer re-encoding query fragments, the runtime marshaller must
397+
// percent-encode reserved URI characters and non-ASCII bytes inside
398+
// deepObject values. Without the fix, '&' splits the value into two
399+
// query params (silent corruption) and non-ASCII bytes produce
400+
// invalid URIs that strict servers reject.
401+
t.Run("deepObject with unicode and reserved chars", func(t *testing.T) {
402+
adversarial := paramclient.ComplexObject{
403+
Object: paramclient.Object{
404+
FirstName: "filter&q=こんにちは",
405+
Role: "admin role+with spaces",
406+
},
407+
Id: 12345,
408+
IsAdmin: true,
409+
}
410+
params := paramclient.GetDeepObjectParams{DeepObj: adversarial}
411+
req, err := paramclient.NewGetDeepObjectRequest(server, &params)
412+
require.NoError(t, err)
413+
var got paramclient.GetDeepObjectParams
414+
doRoundTrip(t, req, &got)
415+
assert.Equal(t, adversarial, got.DeepObj)
416+
})
417+
395418
t.Run("spaceDelimited", func(t *testing.T) {
396419
})
397420

0 commit comments

Comments
 (0)