Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Mix of mapping and list causes error, which is not caught #11567

Closed
ArcticFall opened this issue Mar 1, 2024 · 2 comments
Closed

[BUG] Mix of mapping and list causes error, which is not caught #11567

ArcticFall opened this issue Mar 1, 2024 · 2 comments

Comments

@ArcticFall
Copy link

ArcticFall commented Mar 1, 2024

Description

Using a list of mappings (dashes and colon) in docker compose causes an error, when using docker compose config, that is hard to read and therefore fix.

e.g. the following code mixes a list with mappings:

environment:
  - MYSQL_DATABASE: nextcloud
  - MYSQL_INITDB_SKIP_TZINFO: 1

running docker compose config returns the following error message:
panic: interface conversion: interface {} is string, not map[string]interface {}

It would be better, if this was caught and a meaningful error message would be displayed, the help users fix the error. e.g. a line number and more descriptive text.

see previous discussion in #11267

Steps To Reproduce

Have this in a docker-compose file:

environment:
  - MYSQL_DATABASE: nextcloud
  - MYSQL_INITDB_SKIP_TZINFO: 1

Run: docker compose config
Get error: panic: interface conversion: interface {} is string, not map[string]interface {}

Compose Version

2.24.6

Docker Environment

Client: Docker Engine - Community
Version: 25.0.3
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.24.6
Path: /usr/libexec/docker/cli-plugins/docker-compose

Anything else?

No response

@ndeloof
Copy link
Contributor

ndeloof commented Mar 18, 2024

the following code mixes a list with mappings:

no, you example uses a list of nested mappings, while environment can be set either as list a string or a mapping:

environment:
  - MYSQL_DATABASE=nextcloud
  - MYSQL_INITDB_SKIP_TZINFO=1

or

environment:
  MYSQL_DATABASE: nextcloud
  MYSQL_INITDB_SKIP_TZINFO: 1

still, the error isn't very helpful and compose should not panic, this we have to fix

@ndeloof
Copy link
Contributor

ndeloof commented Mar 20, 2024

Latest release avoids a panic an reports:
failed to load project: services.toto.environment.[0]: unexpected type map[string]interface {}

@ndeloof ndeloof closed this as completed Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants