Skip to content

null yaml value is not written to v #724

@brackendawson

Description

@brackendawson

Describe the bug
When unmarhsalling null or an empty document, the valid result is not written to v.

To Reproduce

playground

package main

import (
	"fmt"

	"github.com/goccy/go-yaml"
)

func main() {
	var v any
	v = 0xdeadbeef
	fmt.Println(yaml.Unmarshal([]byte(""), &v), v)
	fmt.Println(yaml.Unmarshal([]byte("null"), &v), v)
}

Results in:

<nil> 3735928559
<nil> 3735928559

No error but also the result is not written.

Expected behavior
It should be:

<nil> <nil>
<nil> <nil>

Or possibly error unmarshalling null into integer?

Screenshots

Version Variables

  • Go version: 1.24.4
  • go-yaml's Version: 1.17.1

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions