Skip to content

encoding/json: empty fields in json.UnmarshalTypeError #27275

Closed
@Elojah

Description

@Elojah

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

Activity

changed the title [-]Empty fields in json.UnmarshalTypeError[/-] [+]encoding/json: empty fields in json.UnmarshalTypeError[/+] on Aug 27, 2018
agnivade

agnivade commented on Aug 27, 2018

@agnivade
Contributor

/cc @dsnet

added
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on Aug 27, 2018
added this to the Go1.12 milestone on Aug 27, 2018
gopherbot

gopherbot commented on Aug 27, 2018

@gopherbot
Contributor

Change https://golang.org/cl/131675 mentions this issue: encoding/json: add missing struct field context to an error

cirla

cirla commented on Aug 27, 2018

@cirla

It appears that some paths are not calling addErrorContext:

In unmarshal the error returned from value (which never calls error (which called addErrorContext) after this commit) is also returned without ever adding the context.

mvdan

mvdan commented on Aug 27, 2018

@mvdan
Member

Already being fixed by https://go-review.googlesource.com/c/go/+/126897, which was a fix for the similar #26444. Not a duplicate, though.

added a commit that references this issue on Aug 28, 2018
7eea215
gopherbot

gopherbot commented on Aug 28, 2018

@gopherbot
Contributor

Change https://golang.org/cl/126897 mentions this issue: encoding/json: fix UnmarshalTypeError without field and struct values

edaniels

edaniels commented on Aug 28, 2018

@edaniels
Contributor

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

mvdan commented on Aug 28, 2018

@mvdan
Member

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

bradfitz commented on Aug 28, 2018

@bradfitz
Contributor

@gopherbot, please backport to Go 1.11.

8 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bradfitz@edaniels@agnivade@mvdan@gopherbot

        Issue actions

          encoding/json: empty fields in json.UnmarshalTypeError · Issue #27275 · golang/go