Skip to content

Commit f4f3490

Browse files
committed
fix: always write devcontainer.metadata label as JSON array
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 #1054
1 parent 997a2db commit f4f3490

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/spec-node/imageMetadata.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,9 @@ export function getDevcontainerMetadataLabel(devContainerMetadata: SubstitutedCo
497497
if (!metadata.length) {
498498
return '';
499499
}
500-
const imageMetadataLabelValue = metadata.length !== 1
501-
? `[${metadata
502-
.map(feature => ` \\\n${toLabelString(feature)}`)
503-
.join(',')} \\\n]`
504-
: toLabelString(metadata[0]);
500+
const imageMetadataLabelValue = `[${metadata
501+
.map(feature => ` \\\n${toLabelString(feature)}`)
502+
.join(',')} \\\n]`;
505503
return `LABEL ${imageMetadataLabel}="${imageMetadataLabelValue}"`;
506504
}
507505

0 commit comments

Comments
 (0)