Skip to content

fix: isolate document node snapshots - #33

Merged
soulteary merged 1 commit into
mainfrom
fix/document-nodes-deep-copy
Aug 26, 2026
Merged

fix: isolate document node snapshots#33
soulteary merged 1 commit into
mainfrom
fix/document-nodes-deep-copy

Conversation

@soulteary

Copy link
Copy Markdown
Owner

Summary

  • make Document.Nodes() return fully independent node and directive snapshots
  • clone directive argument slices and inline-comment tokens instead of exposing internal mutable references
  • add a regression test that mutates every exported nested value and verifies the document remains unchanged

Verification

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

@soulteary
soulteary merged commit b76fc59 into main Aug 26, 2026

@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: 8d865cb819

ℹ️ 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 pkg/sshconfig/document.go
return nil
}
clone := *directive
clone.Arguments = append([]Argument(nil), directive.Arguments...)

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 non-nil empty argument slices

When AppendDirective or ReplaceDirective is called without arguments, syntheticDirective deliberately stores a non-nil empty Arguments slice, but cloning it with append([]Argument(nil), directive.Arguments...) collapses that value to nil. This makes Nodes() observably change the directive rather than merely copy it: nil checks change and JSON encoding produces null instead of the previous []. Preserve the source slice's nilness while cloning it.

Useful? React with 👍 / 👎.

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