Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/xml: Unmarshal panics when using wrong type with ',innerxml' tag #15600

dominikh opened this Issue May 8, 2016 · 4 comments


None yet
5 participants
Copy link

dominikh commented May 8, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version go1.6.2 linux/amd64
  2. What did you do?
  3. What did you expect to see?
    An error that the type of the field is wrong
  4. What did you see instead?
panic: reflect.Set: value of type []uint8 is not assignable to type []int

goroutine 1 [running]:
panic(0x4f1740, 0xc82000a430)
    /usr/lib/go/src/runtime/panic.go:481 +0x3e6
reflect.Value.assignTo(0x4ea680, 0xc820010320, 0x97, 0x549580, 0xb, 0x4e9120, 0x0, 0x0, 0x0, 0x0)
    /usr/lib/go/src/reflect/value.go:2164 +0x3be
reflect.Value.Set(0x4e9120, 0xc820010240, 0x197, 0x4ea680, 0xc820010320, 0x97)
    /usr/lib/go/src/reflect/value.go:1334 +0x95
encoding/xml.(*Decoder).unmarshal(0xc8200b6000, 0x51a180, 0xc820010240, 0x199, 0xc820014240, 0x0, 0x0)
    /usr/lib/go/src/encoding/xml/read.go:549 +0x1c1b
encoding/xml.(*Decoder).DecodeElement(0xc8200b6000, 0x4e4320, 0xc820010240, 0x0, 0x0, 0x0)
    /usr/lib/go/src/encoding/xml/read.go:133 +0x1c3
encoding/xml.(*Decoder).Decode(0xc8200b6000, 0x4e4320, 0xc820010240, 0x0, 0x0)
    /usr/lib/go/src/encoding/xml/read.go:121 +0x4a
encoding/xml.Unmarshal(0xc820010260, 0x11, 0x20, 0x4e4320, 0xc820010240, 0x0, 0x0)
    /usr/lib/go/src/encoding/xml/read.go:115 +0x270
    /tmp/foo.go:15 +0xcf

@bradfitz bradfitz added this to the Go1.8Maybe milestone May 10, 2016

@quentinmit quentinmit added the NeedsFix label Oct 10, 2016


This comment has been minimized.

Copy link

rsc commented Nov 2, 2016

Good next issue for @quentinmit.


This comment has been minimized.

Copy link

quentinmit commented Nov 8, 2016

The docs say:

If the struct has a field of type []byte or string with tag
",innerxml", Unmarshal accumulates the raw XML nested inside the
element in that field. The rest of the rules still apply.

Given that documentation, I don't believe this should be an error - I think it should be treated as if innerxml had not been specified at all.

@rsc, what do you think?


This comment has been minimized.

Copy link

quentinmit commented Nov 8, 2016

Also, that is already the behavior we have if innerxml is specified on a field that is not a string or a slice.


This comment has been minimized.

Copy link

gopherbot commented Nov 8, 2016

CL mentions this issue.

@gopherbot gopherbot closed this in 48c6048 Nov 9, 2016

@golang golang locked and limited conversation to collaborators Nov 9, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.