compose
compose copied to clipboard
[BUG] Panic when extending a null service
Description
When extends
is used on a null parent service, docker compose crashes with a panic.
panic: interface conversion: interface {} is nil, not map[string]interface {}
goroutine 1 [running]:
github.com/compose-spec/compose-go/v2/loader.ApplyExtends({0x5e57be742248?, 0xc000717c20}, 0x5e57bc6e18c5?, {0xc00005a440, 0x27}, 0xc00021c3f0, 0x5e57bc6e00e5?, {0xc0004d8540, 0x1, 0x1})
github.com/compose-spec/compose-go/[email protected]/loader/extends.go:110 +0x745
github.com/compose-spec/compose-go/v2/loader.loadYamlModel.func1({0x5e57be3843c0?, 0xc000717da0?}, {0xc0004d8540, 0x1, 0x1})
github.com/compose-spec/compose-go/[email protected]/loader/loader.go:316 +0x166
github.com/compose-spec/compose-go/v2/loader.loadYamlModel({0x5e57be742280, 0xc00036c000}, {{0x0, 0x0}, {0xc00005a440, 0x27}, {0xc000716300, 0x1, 0x1}, 0xc000716090}, ...)
github.com/compose-spec/compose-go/[email protected]/loader/loader.go:352 +0x823
github.com/compose-spec/compose-go/v2/loader.load({0x5e57be742280, 0xc00036c000}, {{0x0, 0x0}, {0xc00005a440, 0x27}, {0xc000716300, 0x1, 0x1}, 0xc000716090}, ...)
github.com/compose-spec/compose-go/[email protected]/loader/loader.go:409 +0x3ae
github.com/compose-spec/compose-go/v2/loader.LoadWithContext({0x5e57be742280, 0xc00036c000}, {{0x0, 0x0}, {0xc00005a440, 0x27}, {0xc000716300, 0x1, 0x1}, 0xc000716090}, ...)
github.com/compose-spec/compose-go/[email protected]/loader/loader.go:278 +0x43a
github.com/compose-spec/compose-go/v2/cli.ProjectFromOptions(0xc0002d0000)
github.com/compose-spec/compose-go/[email protected]/cli/options.go:434 +0x58a
github.com/docker/compose/v2/cmd/compose.(*ProjectOptions).ToProject(0xc000614460, {0x5e57be754a80?, 0xc000632f00?}, {0x5e57bf8b9200, 0x0, 0x0}, {0xc0004d9828?, 0x3?, 0x3?})
github.com/docker/compose/v2/cmd/compose/compose.go:216 +0x295
github.com/docker/compose/v2/cmd/compose.upCommand.(*ProjectOptions).WithServices.func4({0x5e57be742280, 0xc00036c000}, {0x5e57bf8b9200, 0x0, 0x0})
github.com/docker/compose/v2/cmd/compose/compose.go:146 +0xee
github.com/docker/compose/v2/cmd/compose.upCommand.(*ProjectOptions).WithServices.Adapt.func6({0x5e57be742280?, 0xc00036c000?}, 0x2?, {0x5e57bf8b9200?, 0x0?, 0x0?})
github.com/docker/compose/v2/cmd/compose/compose.go:108 +0x30
github.com/docker/compose/v2/cmd/compose.upCommand.(*ProjectOptions).WithServices.Adapt.AdaptCmd.func7(0x0?, {0x5e57bf8b9200, 0x0, 0x0})
github.com/docker/compose/v2/cmd/compose/compose.go:87 +0x14e
github.com/docker/compose/v2/cmd/cmdtrace.Setup.wrapRunE.func2(0xc000633000?, {0x5e57bf8b9200?, 0x0?, 0x0?})
github.com/docker/compose/v2/cmd/cmdtrace/cmd_span.go:84 +0x65
github.com/spf13/cobra.(*Command).execute(0xc0002c5b00, {0xc0001319d0, 0x0, 0x0})
github.com/spf13/[email protected]/command.go:983 +0xabc
github.com/spf13/cobra.(*Command).ExecuteC(0xc0004aa900)
github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:1039
github.com/docker/cli/cli-plugins/plugin.RunPlugin(0xc000130e20?, 0xc0002c5800, {{0x5e57bd908682, 0x5}, {0x5e57bd9121da, 0xb}, {0x5e57bdc4d788, 0x6}, {0x0, 0x0}, ...})
github.com/docker/[email protected]+incompatible/cli-plugins/plugin/plugin.go:64 +0x10e
github.com/docker/cli/cli-plugins/plugin.Run(0x5e57be714f90, {{0x5e57bd908682, 0x5}, {0x5e57bd9121da, 0xb}, {0x5e57bdc4d788, 0x6}, {0x0, 0x0}, {0x0, ...}})
github.com/docker/[email protected]+incompatible/cli-plugins/plugin/plugin.go:77 +0xe5
main.pluginMain()
github.com/docker/compose/v2/cmd/main.go:37 +0xa5
main.main()
github.com/docker/compose/v2/cmd/main.go:94 +0x19c
Steps To Reproduce
services:
base:
myservice;
extends: base
Compose Version
Docker Compose version 2.24.1
Docker Environment
Client:
Version: 24.0.7
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: 0.12.1
Path: /usr/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: 2.24.1
Path: /usr/lib/docker/cli-plugins/docker-compose
Anything else?
No response
There's indeed a bug to be fixed here, but I wonder: how did you ended finding this ? Seems it doesn't make any sense to have a null service being extended, isn't it ?
I proposed a fix as https://github.com/compose-spec/compose-go/pull/547/commits/25f05966ff47ce7530d174ab46c274a1f39381e9
There's indeed a bug to be fixed here, but I wonder: how did you ended finding this ? Seems it doesn't make any sense to have a null service being extended, isn't it ?
It's actually quite interesting - base can get different properties by merging other files
@luciangabor ok, that's an unexpected pattern