Skip to content

Compose formatter: preserve YAML anchors#546

Open
bwateratmsft with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-yaml-anchors-formatting
Open

Compose formatter: preserve YAML anchors#546
bwateratmsft with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-yaml-anchors-formatting

Conversation

Copilot AI commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

The Compose document formatter could push a YAML anchor onto its own line, breaking otherwise-valid compose fragments:

# before formatting
x-anchor: &anchor
  FOO: bar

# after formatting (broken)
x-anchor:
  &anchor
  FOO: bar

The formatter serializes via the yaml library's toString. The offending behavior originates in yaml and was fixed upstream in 2.2.2; the pinned yaml@2.9.0 in this repo already emits correct output for the reported example, merge-key (<<: *anchor) usage, sequence/scalar anchors, and the full docker-docs fragment pattern.

Changes

  • Regression test (DocumentFormattingProvider.test.ts): added Should NOT break YAML anchors, formatting the issue's minimal example plus a merge-key alias and asserting the anchor stays inline / document is unchanged. Guards against reintroduction via a dependency downgrade or formatter option change.

No production code changes were required; the test documents and locks in the expected behavior.

Copilot AI changed the title [WIP] Fix compose formatter: YAML anchors broken by formatting Compose formatter: preserve YAML anchors Jul 22, 2026
Copilot AI requested a review from bwateratmsft July 22, 2026 18:53
@bwateratmsft
bwateratmsft requested a review from Copilot July 23, 2026 14:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds coverage to ensure the Compose document formatter does not introduce anchor-breaking newlines, and introduces a Node entrypoint script for the compose language server package.

Changes:

  • Add a regression test to ensure formatting doesn’t push YAML anchors onto a new line (Compose fragments remain valid).
  • Add docker-compose-langserver executable wrapper script under packages/compose-language-service/bin/.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/compose-language-service/src/test/providers/DocumentFormattingProvider.test.ts Adds a formatter regression test for YAML anchor + merge-key (<<) scenarios.
packages/compose-language-service/bin/docker-compose-langserver Adds the npm bin entrypoint wrapper that loads the built CJS server.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bwateratmsft
bwateratmsft marked this pull request as ready for review July 23, 2026 15:08
@bwateratmsft
bwateratmsft requested a review from a team as a code owner July 23, 2026 15:08
@bwateratmsft
bwateratmsft enabled auto-merge (squash) July 23, 2026 19:25
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.

Compose formatter: YAML anchors broken by formatting

3 participants