Compose formatter: preserve YAML anchors#546
Open
bwateratmsft with Copilot wants to merge 3 commits into
Open
Conversation
Copilot
AI
changed the title
[WIP] Fix compose formatter: YAML anchors broken by formatting
Compose formatter: preserve YAML anchors
Jul 22, 2026
Contributor
There was a problem hiding this comment.
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-langserverexecutable wrapper script underpackages/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
approved these changes
Jul 23, 2026
bwateratmsft
marked this pull request as ready for review
July 23, 2026 15:08
bwateratmsft
enabled auto-merge (squash)
July 23, 2026 19:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Compose document formatter could push a YAML anchor onto its own line, breaking otherwise-valid compose fragments:
The formatter serializes via the
yamllibrary'stoString. The offending behavior originates inyamland was fixed upstream in2.2.2; the pinnedyaml@2.9.0in 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
DocumentFormattingProvider.test.ts): addedShould 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.