Closed
Description
What version of Go are you using (go version
)?
go version go1.11 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/hdezier/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/hdezier/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/tq/qnrqmrr14jvb912sj71lc24w0000gp/T/go-build337010521=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Unmarshaling an invalid json data field int
into a string
with json.NewDecoder(data).Decode(&f)
https://play.golang.org/p/0ChwR84YV_v
What did you expect to see?
In go 1.10.3 (current goplayground), e.Struct
and e.Field
are correctly set
What did you see instead?
In go 1.11 those values are empty
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
[-]Empty fields in json.UnmarshalTypeError[/-][+]encoding/json: empty fields in json.UnmarshalTypeError[/+]agnivade commentedon Aug 27, 2018
/cc @dsnet
gopherbot commentedon Aug 27, 2018
Change https://golang.org/cl/131675 mentions this issue:
encoding/json: add missing struct field context to an error
cirla commentedon Aug 27, 2018
It appears that some paths are not calling
addErrorContext
:In
unmarshal
the error returned fromvalue
(which never callserror
(which calledaddErrorContext
) after this commit) is also returned without ever adding the context.mvdan commentedon Aug 27, 2018
Already being fixed by https://go-review.googlesource.com/c/go/+/126897, which was a fix for the similar #26444. Not a duplicate, though.
encoding/json: fix UnmarshalTypeError without field and struct values
gopherbot commentedon Aug 28, 2018
Change https://golang.org/cl/126897 mentions this issue:
encoding/json: fix UnmarshalTypeError without field and struct values
edaniels commentedon Aug 28, 2018
Can this be made to be go 1.11.1 https://github.com/golang/go/milestone/80? This prevents us from an upgrade to go 1.11 in production.
mvdan commentedon Aug 28, 2018
Perhaps so - it is a regression, and the CL is small, so it seems doable to me. cc @bradfitz @dsnet @rsc for a decision on that.
bradfitz commentedon Aug 28, 2018
@gopherbot, please backport to Go 1.11.
8 remaining items