Skip to content

dev_container: Handle devcontainer.metadata label as JSON object or array - #53557

Merged
KyleBarton merged 2 commits into
zed-industries:mainfrom
fechu:fix/devcontainer-metadata-object-deserialization
Apr 10, 2026
Merged

KyleBarton merged 2 commits into
zed-industries:mainfrom
fechu:fix/devcontainer-metadata-object-deserialization

Conversation

@fechu

@fechu fechu commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Details

  • The devcontainer CLI writes the devcontainer.metadata label as a bare JSON object when there is only one metadata entry (e.g. docker-compose devcontainer with a Dockerfile and no features)
  • Zed's deserialize_metadata only accepted a JSON array, causing deserialization to fail with invalid type: map, expected a sequence
  • This made it impossible to attach to existing docker-compose devcontainers created by the devcontainer CLI or VS Code

The fix tries parsing as an array first, then falls back to parsing as a single object wrapped in a vec. This mirrors how the devcontainer CLI itself reads the label.

An upstream fix has also been submitted: devcontainers/cli#1199

Reproduction

  1. Create a docker-compose devcontainer with a Dockerfile and no features:

.devcontainer/devcontainer.json:

{
  "name": "repro",
  "dockerComposeFile": "docker-compose.yml",
  "service": "app",
  "remoteUser": "root"
}

.devcontainer/docker-compose.yml:

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    command: sleep infinity
    volumes:
      - ..:/workspace

.devcontainer/Dockerfile:

FROM ubuntu:24.04
  1. devcontainer up --workspace-folder .
  2. Open the folder in Zed, fails with metadata deserialization error

Release Notes:

  • Fixed attaching to a devcontainer that has a single metadata element which was started with devcontainer-cli

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
@cla-bot

cla-bot Bot commented Apr 9, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @fechu on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Apr 9, 2026
@fechu

fechu commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 9, 2026
@cla-bot

cla-bot Bot commented Apr 9, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@fechu
fechu marked this pull request as ready for review April 9, 2026 21:32
@zed-codeowner-coordinator
zed-codeowner-coordinator Bot requested review from a team, SomeoneToIgnore and reflectronic and removed request for a team April 9, 2026 21:32
@maxdeviant maxdeviant changed the title fix: handle devcontainer.metadata label as JSON object or array dev_container: Handle devcontainer.metadata label as JSON object or array Apr 9, 2026
@SomeoneToIgnore
SomeoneToIgnore removed their request for review April 10, 2026 09:19
@KyleBarton
KyleBarton self-requested a review April 10, 2026 15:13

@KyleBarton KyleBarton left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@fechu thanks for this, good catch!

@KyleBarton
KyleBarton merged commit 2d3f49e into zed-industries:main Apr 10, 2026
39 checks passed
@zed-industries-bot

Copy link
Copy Markdown
Contributor
Messages
📖

This PR includes links to the following GitHub Issues: #devcontainers/cli#1054
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against 9ade796

piper-of-dawn pushed a commit to piper-of-dawn/zed that referenced this pull request Apr 25, 2026
…rray (zed-industries#53557)

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Details

- The [devcontainer CLI writes the `devcontainer.metadata` label as a
bare JSON object](devcontainers/cli#1054) when
there is only one metadata entry (e.g. docker-compose devcontainer with
a Dockerfile and no features)
- Zed's `deserialize_metadata` only accepted a JSON array, causing
deserialization to fail with `invalid type: map, expected a sequence`
- This made it impossible to attach to existing docker-compose
devcontainers created by the devcontainer CLI or VS Code

The fix tries parsing as an array first, then falls back to parsing as a
single object wrapped in a vec. This mirrors how the [devcontainer CLI
itself reads the
label](https://github.com/devcontainers/cli/blob/main/src/spec-node/imageMetadata.ts#L476-L493).

An upstream fix has also been submitted:
devcontainers/cli#1199

## Reproduction

1. Create a docker-compose devcontainer with a Dockerfile and no
features:

`.devcontainer/devcontainer.json`:
```json
{
  "name": "repro",
  "dockerComposeFile": "docker-compose.yml",
  "service": "app",
  "remoteUser": "root"
}
```

`.devcontainer/docker-compose.yml`:
```yaml
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    command: sleep infinity
    volumes:
      - ..:/workspace
```

`.devcontainer/Dockerfile`:
```dockerfile
FROM ubuntu:24.04
```

2. `devcontainer up --workspace-folder .`
3. Open the folder in Zed, fails with metadata deserialization error

Release Notes:

- Fixed attaching to a devcontainer that has a single metadata element
which was started with `devcontainer-cli`
Zenor27 pushed a commit to Zenor27/zed that referenced this pull request Jul 4, 2026
…rray (zed-industries#53557)

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Details

- The [devcontainer CLI writes the `devcontainer.metadata` label as a
bare JSON object](devcontainers/cli#1054) when
there is only one metadata entry (e.g. docker-compose devcontainer with
a Dockerfile and no features)
- Zed's `deserialize_metadata` only accepted a JSON array, causing
deserialization to fail with `invalid type: map, expected a sequence`
- This made it impossible to attach to existing docker-compose
devcontainers created by the devcontainer CLI or VS Code

The fix tries parsing as an array first, then falls back to parsing as a
single object wrapped in a vec. This mirrors how the [devcontainer CLI
itself reads the
label](https://github.com/devcontainers/cli/blob/main/src/spec-node/imageMetadata.ts#L476-L493).

An upstream fix has also been submitted:
devcontainers/cli#1199

## Reproduction

1. Create a docker-compose devcontainer with a Dockerfile and no
features:

`.devcontainer/devcontainer.json`:
```json
{
  "name": "repro",
  "dockerComposeFile": "docker-compose.yml",
  "service": "app",
  "remoteUser": "root"
}
```

`.devcontainer/docker-compose.yml`:
```yaml
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    command: sleep infinity
    volumes:
      - ..:/workspace
```

`.devcontainer/Dockerfile`:
```dockerfile
FROM ubuntu:24.04
```

2. `devcontainer up --workspace-folder .`
3. Open the folder in Zed, fails with metadata deserialization error

Release Notes:

- Fixed attaching to a devcontainer that has a single metadata element
which was started with `devcontainer-cli`
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…rray (zed-industries#53557)

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Details

- The [devcontainer CLI writes the `devcontainer.metadata` label as a
bare JSON object](devcontainers/cli#1054) when
there is only one metadata entry (e.g. docker-compose devcontainer with
a Dockerfile and no features)
- Zed's `deserialize_metadata` only accepted a JSON array, causing
deserialization to fail with `invalid type: map, expected a sequence`
- This made it impossible to attach to existing docker-compose
devcontainers created by the devcontainer CLI or VS Code

The fix tries parsing as an array first, then falls back to parsing as a
single object wrapped in a vec. This mirrors how the [devcontainer CLI
itself reads the
label](https://github.com/devcontainers/cli/blob/main/src/spec-node/imageMetadata.ts#L476-L493).

An upstream fix has also been submitted:
devcontainers/cli#1199

## Reproduction

1. Create a docker-compose devcontainer with a Dockerfile and no
features:

`.devcontainer/devcontainer.json`:
```json
{
  "name": "repro",
  "dockerComposeFile": "docker-compose.yml",
  "service": "app",
  "remoteUser": "root"
}
```

`.devcontainer/docker-compose.yml`:
```yaml
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    command: sleep infinity
    volumes:
      - ..:/workspace
```

`.devcontainer/Dockerfile`:
```dockerfile
FROM ubuntu:24.04
```

2. `devcontainer up --workspace-folder .`
3. Open the folder in Zed, fails with metadata deserialization error

Release Notes:

- Fixed attaching to a devcontainer that has a single metadata element
which was started with `devcontainer-cli`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants