Skip to content

fix: reject ambiguous legacy documents - #35

Merged
soulteary merged 1 commit into
mainfrom
fix/strict-legacy-decode
Aug 26, 2026
Merged

fix: reject ambiguous legacy documents#35
soulteary merged 1 commit into
mainfrom
fix/strict-legacy-decode

Conversation

@soulteary

Copy link
Copy Markdown
Owner

Summary

  • use YAML strict decoding so misspelled and duplicate nested fields cannot be silently ignored
  • disallow unknown JSON object fields
  • require JSON input to contain exactly one document, rejecting extra values and trailing tokens
  • retain valid legacy YAML and JSON behavior with positive coverage

Verification

  • go test ./...
  • go test -race ./...
  • go vet ./...
  • git diff --check

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 422853e155

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/fn/fn.go
// type errors from callers that must avoid destructive conversions.
func GetYamlDataStrict(input string) (yamlConfig Define.YAMLOutput, err error) {
err = yaml.Unmarshal([]byte(input), &yamlConfig)
err = yaml.UnmarshalStrict([]byte(input), &yamlConfig)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve valid YAML merge-key overrides

When a legacy map uses a YAML merge key and then explicitly overrides one of the merged entries—for example global: {<<: *defaults, User: bob}yaml.UnmarshalStrict reports the explicit User as a duplicate and rejects the document. YAML merge semantics permit explicit keys to override merged values, and the previous decoder accepted these files, so existing legacy configurations using anchors can no longer be converted; duplicate detection needs to distinguish literal duplicate keys from merge overrides.

Useful? React with 👍 / 👎.

@soulteary
soulteary merged commit 802cf78 into main Aug 26, 2026
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.

1 participant