You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the addition of sonic as the default json decoder, we've found that okx does not unmarshal responses correctly.
Specifically, okx's SendHTTPRequest accepts any which should contain a pointer to something.
It then tries to wrap that in another slice of any in most situations, depending on the useAsItIs flag and the type of the data.
The issue is that sonic replaces the pointer inside the top slice, and so the caller's pointer is never changed.
The cleanest way to reproduce this I've found so far is:
func TestSonic(t *testing.T) {
a := []string{}
b := []any{&a}
if err := sonic.ConfigStd.Unmarshal([]byte(`[["one","2"]]`), &b); err != nil {
t.Fatalf("Unmarshal must not error: %s", err)
}
if _, ok := b[0].(*[]string); !ok {
t.Fatalf("b[0] must still a *[]string; Got: %T", b[0])
}
if b[0] != &a {
t.Error("b[0] must still be *a")
}
}
Giving:
GOARCH=arm64 go test ./exchanges/okx/... -run TestSonic
--- FAIL: TestSonic (0.00s)
okx_test.go:598: b[0] must still a *[]string; Got: []interface {}
versus:
GOARCH=amd64 go test ./exchanges/okx/... -run TestSonic
--- PASS: TestSonic (0.01s)
Which yields an interesting difference on arm64, in that it can't even assert *[]string.
We've considered sidestepping this by changing okx's behaviour, but it's non-trivial and dirty.
For now #1794 is merged to turn sonic off for arm64 until this is fixed.
This issue is to track the solution in sonic, and any other possible mitigations we might come up with in the meantime.
The text was updated successfully, but these errors were encountered:
Updated test to remove more superfluous distractions.
This happens on any [] any that contains pointers, and doesn't need an object wrapper.
Also stripped out assert, so we can use-as is with sonic team.
With the addition of sonic as the default json decoder, we've found that okx does not unmarshal responses correctly.
Specifically, okx's SendHTTPRequest accepts
any
which should contain a pointer to something.It then tries to wrap that in another slice of any in most situations, depending on the
useAsItIs
flag and the type of the data.The issue is that sonic replaces the pointer inside the top slice, and so the caller's pointer is never changed.
The cleanest way to reproduce this I've found so far is:
Giving:
versus:
Which yields an interesting difference on arm64, in that it can't even assert
*[]string
.We've considered sidestepping this by changing okx's behaviour, but it's non-trivial and dirty.
For now #1794 is merged to turn sonic off for arm64 until this is fixed.
This issue is to track the solution in sonic, and any other possible mitigations we might come up with in the meantime.
The text was updated successfully, but these errors were encountered: