Config.UseUnicodeErrors is ignored by Config.Froze
Describe the bug
Config.UseUnicodeErrors is documented as making decoding fail on invalid Unicode escape sequences, but Config.Froze does not propagate the flag to the decoder options. The equivalent low-level decoder option works as documented.
Affected commit: 2a36d6da63e25b9080cc4e11398bd5b3512dfc2a (current main).
To Reproduce
package main
import (
"fmt"
"github.com/bytedance/sonic"
"github.com/bytedance/sonic/decoder"
)
func main() {
var configured string
configErr := sonic.Config{UseUnicodeErrors: true}.Froze().UnmarshalFromString(`"\ud800"`, &configured)
var direct string
dec := decoder.NewDecoder(`"\ud800"`)
dec.UseUnicodeErrors()
directErr := dec.Decode(&direct)
fmt.Printf("config: err=%v value=%q\ndirect: err=%v\n", configErr, configured, directErr)
}Output:
config: err=<nil> value="�"
direct: err=Syntax error at index 3: invalid unicode escape ...Expected behavior
The frozen config should enable the same decoder option as decoder.Decoder.UseUnicodeErrors, and the first decode should return an invalid-Unicode error.
Sonic version:
Current main at 2a36d6da63e25b9080cc4e11398bd5b3512dfc2a (also affects the configuration code in v1.15.2).
Environment:
go version go1.26.3 windows/amd64
GOOS=windows
GOARCH=amd64
CGO_ENABLED=0Additional context
api.go defines the field and the internal decoder has OptionUseUnicodeErrors, but the mapping in Config.Froze handles the surrounding decoder options without handling this one. A focused config regression test should cover the public path.
Source: bytedance/sonic