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

Yaml Path panics with invalid path #595

Open
gkampitakis opened this issue Dec 15, 2024 · 0 comments
Open

Yaml Path panics with invalid path #595

gkampitakis opened this issue Dec 15, 2024 · 0 comments
Labels
bug Something isn't working yamlpath

Comments

@gkampitakis
Copy link

gkampitakis commented Dec 15, 2024

Describe the bug

Hey, thanks a lot for creating and maintaining this library. I have started exploring this library as part of extending a snapshot testing library that I have https://github.com/gkampitakis/go-snaps and I want to support YAML snapshots. I was looking into yaml.PathString and when I pass a path with starting with a dot it panics.

Also apart from the README.md I can't find any examples or documentation for the valid yaml path syntax, maybe I missed it.

To Reproduce

package main

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

func main() {
	yaml.PathString(".address")
}


/**
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x20 pc=0x104765254]

goroutine 1 [running]:
github.com/goccy/go-yaml.(*PathBuilder).child(...)
*/

Please provide a minimum yaml content that can be reproduced.
We are more than happy to use Go Playground

Expected behavior

I would expect an error if this is invalid path.

Version Variables

  • Go version: 1.23.2
  • go-yaml's Version: v1.15.10

Additional context
Add any other context about the problem here.

@gkampitakis gkampitakis added the bug Something isn't working label Dec 15, 2024
@goccy goccy added the yamlpath label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working yamlpath
Projects
None yet
Development

No branches or pull requests

2 participants