refactor(tracker): use UnmarshalStrict when decoding embedded yamls

Since we have 100% control over what data gets embedded, there is no
reason to embed anything that doesn't pass the strict yaml parsing
and it's better we throw a panic right away so it's easy to catch
this during development.
This commit is contained in:
5684185+vsariola@users.noreply.github.com 2025-05-23 21:44:23 +03:00
parent 27bf8220c0
commit ddbaf6a4bb
3 changed files with 4 additions and 4 deletions

View File

@ -41,7 +41,7 @@ var defaultKeyBindingsYaml []byte
func loadDefaultKeyBindings() []KeyBinding {
var keyBindings []KeyBinding
err := yaml.Unmarshal(defaultKeyBindingsYaml, &keyBindings)
err := yaml.UnmarshalStrict(defaultKeyBindingsYaml, &keyBindings)
if err != nil {
panic(fmt.Errorf("failed to unmarshal keybindings: %w", err))
}

View File

@ -29,7 +29,7 @@ var defaultPreferencesYaml []byte
func loadDefaultPreferences() Preferences {
var preferences Preferences
err := yaml.Unmarshal(defaultPreferencesYaml, &preferences)
err := yaml.UnmarshalStrict(defaultPreferencesYaml, &preferences)
if err != nil {
panic(fmt.Errorf("failed to unmarshal preferences: %w", err))
}

View File

@ -11,7 +11,7 @@ import (
"github.com/vsariola/sointu"
"github.com/vsariola/sointu/vm"
"gopkg.in/yaml.v3"
"gopkg.in/yaml.v2"
)
//go:generate go run generate/main.go
@ -180,7 +180,7 @@ func init() {
return nil
}
var instr sointu.Instrument
if yaml.Unmarshal(data, &instr) == nil {
if yaml.UnmarshalStrict(data, &instr) == nil {
noExt := path[:len(path)-len(filepath.Ext(path))]
splitted := splitPath(noExt)
splitted = splitted[1:] // remove "presets" from the path