Skip to content

Fix yaml marshalling#1844

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:fix-config-marshalling
Feb 25, 2026
Merged

Fix yaml marshalling#1844
dgageot merged 1 commit intodocker:mainfrom
dgageot:fix-config-marshalling

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Feb 25, 2026

Sometimes, the yaml configuration marshalling was broken and produced yaml files that couldn't be parsed.

e.g. running cagent share push and then cagent share pull would produce a corrupted yaml.

See #1797

Signed-off-by: David Gageot <david.gageot@docker.com>
@dgageot dgageot requested a review from a team as a code owner February 25, 2026 09:16
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

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

Review Summary

✅ This PR correctly fixes the YAML marshalling issue by updating custom MarshalYAML methods to return (any, error) instead of ([]byte, error). The pattern of returning raw values instead of calling yaml.Marshal() is the correct approach for the yaml.v3 Marshaler interface.

The new test TestParseExamplesAfterMarshalling provides good validation that configs can successfully round-trip through marshalling and unmarshalling, which should prevent the corruption issues mentioned in the PR description.

No issues found in the changed code.

@dgageot dgageot merged commit ae7e845 into docker:main Feb 25, 2026
8 checks passed
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