]> git.maquefel.me Git - brevno-suite/hugo/commit
parser/metadecoder: Improve errors for non-map XML root values
authorVille Vesilehto <ville@vesilehto.fi>
Sat, 22 Mar 2025 17:48:23 +0000 (19:48 +0200)
committerGitHub <noreply@github.com>
Sat, 22 Mar 2025 17:48:23 +0000 (18:48 +0100)
commitf34cdc382a1f8df8ffef3772e289225e6fd52d93
tree3dbcb09d85f15206b5f6772aca0b194cf406f8a3
parent52561d561a591a6fb757b6d417138e0a79bce790
parser/metadecoder: Improve errors for non-map XML root values

Previously, the XML decoder would panic when encountering a root element with
a non-map value due to an unsafe type assertion.

The fix adds proper type checking before the map conversion and provides
clear error messages to help users identify and fix invalid XML structures.

Example error for invalid XML like:
<root>just text</root>

Will now return:
"XML root element 'root' must be a map/object, got string"
parser/metadecoders/decoder.go
parser/metadecoders/decoder_test.go