Skip to content

Conversation

@piotrek-janus
Copy link
Contributor

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 WeaklyTypedInput in mapstructure decoder to ensure strict type handling
  • Added StringifyNumbers option to ToYaml function to properly handle numeric values in JSON encoding
  • Created new FromYaml utility 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 {
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
func postProcessMultilineTemplates(bts []byte) []byte {
func postProcessMultilineTemplates(bts []byte) []byte {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants