Skip to content

fix: prevent nil map panic when docker-compose.yaml has top-level name field#3204

Open
raman1236 wants to merge 1 commit intodevspace-sh:mainfrom
raman1236:fix/nil-map-docker-compose-named-project
Open

fix: prevent nil map panic when docker-compose.yaml has top-level name field#3204
raman1236 wants to merge 1 commit intodevspace-sh:mainfrom
raman1236:fix/nil-map-docker-compose-named-project

Conversation

@raman1236
Copy link
Copy Markdown

Summary

Fixes #2970

When a docker-compose.yaml includes a top-level name: field (e.g. name: myproject), devspace init panics with:

panic: assignment to entry in nil map

Root Cause

In pkg/devspace/compose/manager.go, LoadDockerComposeProject passes a ConfigDetails struct to the compose-go loader without initializing the Environment field. When the compose file has a name: field, the loader tries to write to configDetails.Environment (in vendor/.../loader/loader.go line 218), which is nil.

Fix

Initialize Environment to an empty map in the ConfigDetails struct passed to composeloader.Load().

Testing

  • Added a new named_project test case under pkg/devspace/compose/testdata/ with a docker-compose.yaml containing name: myproject
  • All existing compose tests continue to pass
  • The new test case triggers the previously-panicking code path and now succeeds

…e field

When a docker-compose.yaml includes a top-level 'name:' field, the
compose-go loader attempts to assign to ConfigDetails.Environment which
is nil, causing a panic.

Initialize the Environment map to an empty map before calling the loader.

Fixes devspace-sh#2970
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 5, 2026

Deploy Preview for devspace-docs canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit cd043fb
🔍 Latest deploy log https://app.netlify.com/projects/devspace-docs/deploys/69d1d4dcec1747000806ec2a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: assignment to entry in nil map

2 participants