Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes unexpected type casting issues when converting between YAML and Go data structures, specifically handling numeric values. The change disables weak typing in the mapstructure decoder to prevent unwanted type conversions, adds StringifyNumbers option to JSON encoding, and introduces a new FromYaml utility function to centralize YAML unmarshaling logic.
Key changes:
- Disabled
WeaklyTypedInputin mapstructure decoder to ensure strict type handling - Added
StringifyNumbersoption toToYamlfunction to properly handle numeric values in JSON encoding - Created new
FromYamlutility function to centralize YAML unmarshaling with proper error handling
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/cac/utils/yaml.go | Added FromYaml function and StringifyNumbers option to ToYaml for consistent number handling |
| internal/cac/utils/yaml_test.go | Added tests for encoding and decoding numbers to validate the fix |
| internal/cac/utils/decoder.go | Changed WeaklyTypedInput from true to false to prevent unwanted type coercion |
| internal/cac/storage/reader.go | Updated to use new FromYaml utility function instead of direct ccyaml.Unmarshal call |
| internal/cac/storage/writer.go | Added extraneous whitespace in function declaration (formatting issue) |
| internal/cac/utils/model_test.go | Added tests for mapping numbers between models and YAML/patch operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var multilineTemplateRegexp = regexp.MustCompile(`⌘⌘(\d+) ([^⌘]+)⌘⌘`) | ||
|
|
||
| func postProcessMultilineTemplates(bts []byte) []byte { | ||
| func postProcessMultilineTemplates(bts []byte) []byte { |
There was a problem hiding this comment.
Extra whitespace between 'func' and function name. This appears to be unintended formatting noise. The tab character should be removed to maintain consistent code formatting.
| func postProcessMultilineTemplates(bts []byte) []byte { | |
| func postProcessMultilineTemplates(bts []byte) []byte { |
No description provided.