fix: always write devcontainer.metadata label as JSON array#1199
Open
fechu wants to merge 3 commits intodevcontainers:mainfrom
Open
fix: always write devcontainer.metadata label as JSON array#1199fechu wants to merge 3 commits intodevcontainers:mainfrom
fechu wants to merge 3 commits intodevcontainers:mainfrom
Conversation
When there is only one metadata entry (e.g. docker-compose devcontainer with no features), `getDevcontainerMetadataLabel` wrote a bare JSON object instead of an array. This violates the spec which states the label "can contain an array of json snippets" and causes tools like Zed that expect an array to fail when attaching to an existing container. Always wrap the metadata in an array regardless of the number of entries. Spec reference: https://containers.dev/implementors/json_reference/ Fixes devcontainers#1054
Author
|
@microsoft-github-policy-service agree |
fechu
added a commit
to fechu/zed
that referenced
this pull request
Apr 9, 2026
The devcontainer CLI writes the `devcontainer.metadata` container label as a bare JSON object when there is only one metadata entry (e.g. docker-compose with a Dockerfile and no features). This causes deserialization to fail because the current code only accepts a JSON array. Try parsing as an array first, then fall back to parsing as a single object wrapped in a vec. Upstream CLI fix: devcontainers/cli#1199 Related CLI issue: devcontainers/cli#1054
Open
5 tasks
abdurriq
approved these changes
Apr 10, 2026
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
getDevcontainerMetadataLabelfunction wrote a bare JSON object when there was only one metadata entry (e.g. docker-compose devcontainer with no features), but an array when there were multiple entriesThe reading side (
internalGetImageMetadata0) already handles both formats, but the writing side was inconsistent. In this PR we propose to always write an array of objects for simplicity. For backwards compatibility we leave the parsing, which supports both. Changing this makes the code follow the robustness principle by being strict what is returned (always an array).Test instructions
Create the following project:
devcontainer.json:
docker-compose.yml:
Dockerfile
With the latest release the metadata is:
After this change:
Fixes #1054