compose-go icon indicating copy to clipboard operation
compose-go copied to clipboard

Service called "extensions" throws exception in loader

Open jonathanwinter123 opened this issue 2 years ago • 1 comments

Apparently calling a service in a docker-compose file "extensions" is not allowed. I didn't find any mention about it being a keyword or anything else in the docker-compose file reference so I think it's a bug.

How to reproduce: Create a docker-compose file with a service called "extensions" try to up the service (or any service else in the docker-compose for that matter).

Following exception will be thrown:

panic: interface conversion: interface {} is string, not map[string]interface {}

goroutine 1 [running]:
github.com/compose-spec/compose-go/loader.loadServiceWithExtends({0xc0001df8c0, 0x3c}, {0xc0000388ca, 0x5}, 0xc0005bdf20, {0xc0000c8090, 0x29}, 0x23dce26def9, 0xc000047020, 0xc00061e350)
        github.com/compose-spec/[email protected]/loader/loader.go:491 +0x6ab
github.com/compose-spec/compose-go/loader.LoadServices({0xc0001df8c0, 0x3c}, 0x190d525, {0xc0000c8090, 0x29}, 0x0, 0x6f439bc26e497e4)
        github.com/compose-spec/[email protected]/loader/loader.go:470 +0x1d1
github.com/compose-spec/compose-go/loader.loadSections({0xc0001df8c0, 0x3c}, 0x0, {{0x0, 0x0}, {0xc0000c8090, 0x29}, {0xc0005981e0, 0x2, 0x2}, ...}, ...)
        github.com/compose-spec/[email protected]/loader/loader.go:295 +0x2f4
github.com/compose-spec/compose-go/loader.Load({{0x0, 0x0}, {0xc0000c8090, 0x29}, {0xc0005981e0, 0x2, 0x2}, 0xc000046a50}, {0xc0005861f0, 0x2, ...})
        github.com/compose-spec/[email protected]/loader/loader.go:183 +0x912
github.com/compose-spec/compose-go/cli.ProjectFromOptions(0xc000403730)
        github.com/compose-spec/[email protected]/cli/options.go:337 +0x29e
github.com/docker/compose/v2/cmd/compose.(*projectOptions).toProject(0xc0000d7780, {0xc00041bdd0, 0x10000c00083fab8, 0x3}, {0xc00083fa78, 0x18, 0x23da8f62588})
        github.com/docker/compose/v2/cmd/compose/compose.go:158 +0x76
github.com/docker/compose/v2/cmd/compose.(*projectOptions).WithServices.func1({0x1ae9340, 0xc0002b6040}, {0xc00041bdd0, 0x1, 0x3})
        github.com/docker/compose/v2/cmd/compose/compose.go:120 +0x98
github.com/docker/compose/v2/cmd/compose.Adapt.func1({0x1ae9340, 0xc0002b6040}, 0x2, {0xc00041bdd0, 0x1, 0xc00083fb20})
        github.com/docker/compose/v2/cmd/compose/compose.go:87 +0x36
github.com/docker/compose/v2/cmd/compose.AdaptCmd.func1(0xc00033ef00, {0xc00041bdd0, 0x1, 0x3})
        github.com/docker/compose/v2/cmd/compose/compose.go:66 +0x223
github.com/spf13/cobra.(*Command).execute(0xc00033ef00, {0xc00007e7f0, 0x3, 0x3})
        github.com/spf13/[email protected]/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc00045b180)
        github.com/spf13/[email protected]/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:902
github.com/docker/cli/cli-plugins/plugin.RunPlugin(0xc000073e28, 0xc00033ec80, {{0x19086a4, 0x5}, {0x190fedf, 0xb}, {0x1aafba0, 0x6}, {0x0, 0x0}, ...})
        github.com/docker/[email protected]+incompatible/cli-plugins/plugin/plugin.go:51 +0x130
github.com/docker/cli/cli-plugins/plugin.Run(0x198c118, {{0x19086a4, 0x5}, {0x190fedf, 0xb}, {0x1aafba0, 0x6}, {0x0, 0x0}, {0x0, ...}, ...})
        github.com/docker/[email protected]+incompatible/cli-plugins/plugin/plugin.go:64 +0xee
main.pluginMain()
        github.com/docker/compose/v2/cmd/main.go:41 +0xdf
main.main()
        github.com/docker/compose/v2/cmd/main.go:74 +0x1de

My setup: Docker Desktop for Windows Version: 4.6.1 Engine: 20.10.13 Compose: 2.3.3 Credential Helper: 0.6.4 Kubernetes: 1.22.5 Snyk: 1.827.0

I hope this is the correct repo to post this issue because the exception is being thrown by compose-go/loader.loadServiceWithExtends routine. If you need anything else, just let me know.

jonathanwinter123 avatar Apr 11 '22 13:04 jonathanwinter123

extension is indeed used internally to collect all x-.. attributes. This is unfortunate. I'll look into a fix

ndeloof avatar Apr 30 '22 08:04 ndeloof

Perfect, thank you very much. Will try it out in the next few weeks

jonathanwinter123 avatar Mar 20 '23 09:03 jonathanwinter123