vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

Dev Containers: YAMLException for !reset [] tag

Open seantfish opened this issue 2 years ago • 5 comments

  • VSCode Version: 1.80.1

  • Local OS Version: Windows 11

  • Remote Extension: Dev Containers (pre-release v0.302.0)

  • Logs:

[2023-07-20T21:44:03.339Z] Start: Updating configuration state
[2023-07-20T21:44:03.350Z] YAMLException: unknown tag !<!reset> (15:21)

 12 |   # Sonar node
 13 |   sonar_process:
 14 |     # exposing ports to Docker container for udp to ...
 15 |     ports: !reset []
--------------------------^
 16 |     # launches multiple ROS2 nodes, see sonar_proce ...
 17 |     command: sleep infinity
	at T6 (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:236:947)
	at ve (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:236:982)
	at xm (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:5823)
	at fEe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:2158)
	at xm (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:4897)
	at fEe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:2158)
	at xm (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:4897)
	at fEe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:2158)
	at xm (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:4897)
	at vEe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:243:7289)
	at I6 (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:244:260)
	at xEe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:244:474)
	at SO (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:264:2634)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async X6 (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:264:1921)
	at async LC (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:264:1858)
	at async hbe (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:265:6019)
	at async jO (c:\Users\Sean\.vscode\extensions\ms-vscode-remote.remote-containers-0.299.0\dist\extension\extension.js:268:5194)

Steps to Reproduce:

  1. Create a devcontainer.json referencing two Docker Compose files ("dockerComposeFile") with one extending the other, with the first file setting up a service with a port defined under field ports and the extending file overriding that field with ports: !reset []
  2. Build and open container

Does this issue occur when you try this locally?: Yes Does this issue occur when you try this locally and all extensions are disabled?: No other extensions installed

!reset is a recent addition in the compose specification, but Docker is updated and able to parse the !reset tag and start the container. The issue appears to occur when the extension tries to read the file.

seantfish avatar Jul 20 '23 22:07 seantfish

i'd like to add to that: the use of !reset null is met with the same error too.

[2023-08-16T11:43:41.501Z] YAMLException: unknown tag !<!reset> (3:23)

 1 | services:
 2 |   backend:
 3 |     build: !reset null
---------------------------^
 4 |     image: mcr.microsoft.com/devcontainers/python:1-3. ...
 5 |     command: sleep infinity
	at N6 (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:243:947)
	at ve (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:243:982)
	at Em (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:5823)
	at TEe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:2158)
	at Em (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:4897)
	at TEe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:2158)
	at Em (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:4897)
	at TEe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:2158)
	at Em (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:4897)
	at AEe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:250:7289)
	at L6 (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:251:260)
	at kEe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:251:474)
	at kO (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:271:2634)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async iK (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:271:1921)
	at async qC (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:271:1858)
	at async Pbe (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:272:6047)
	at async zO (c:\Users\mail\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\dist\extension\extension.js:275:5396)

official compose documentation can be found here: https://docs.docker.com/compose/compose-file/13-merge/

elgarfo avatar Aug 16 '23 11:08 elgarfo

at least i found a workaround. although this requires docker compose on the host:

the idea is to use docker compose -f docker-compose.yml -f docker-compose.devcontainer.yml config to get the rendered compose config. then store that and configure devcontainer.json to use that rendered file.

i've modified my devcontainer.json to this:

{
  "name": "dc/py3",
  "initializeCommand": "docker compose -f ./docker-compose.yml -f .devcontainer/docker-compose.devcontainer.yml config > .docker-compose.rendered.yml",
  // "dockerComposeFile": [ "../docker-compose.yml", "./docker-compose.devcontainer.yml" ],
  "dockerComposeFile": "../.docker-compose.rendered.yml",
  "service": "backend",
  "workspaceFolder": "/workspace",
  "shutdownAction": "stopCompose",
  "runServices": [ "rabbitmq" ]
}

⚠️ the "initializeCommand" is executed inside the projects root. NOT inside of .devcontainer/

i've tested this on windows 11 with docker (and docker compose) installed inside a debian 11 WSL2.

the lifecycle hook "initializeCommand" is documented here: https://containers.dev/implementors/json_reference/#lifecycle-scripts

elgarfo avatar Aug 16 '23 13:08 elgarfo

There appears to be a way to add custom tags to the js-yaml module we are using for parsing: https://github.com/nodeca/js-yaml/blob/master/examples/handle_unknown_types.js

chrmarti avatar Aug 22 '23 13:08 chrmarti

I am facing the same issue. @chrmarti can we please solve this issue?

g-kartik avatar Mar 20 '24 08:03 g-kartik

Same goes for override tag too. It is also not recognized.

g-kartik avatar Mar 29 '24 07:03 g-kartik