Skip to content

🐞 Container.EnvVariables fails #3860

Closed

Description

@jlongtine

What is the issue?

Container.EnvVariables fails with the following error:

input:1: Field "envVariables" of type "[EnvVariable!]!" must have a sub selection.
package main

import (
	"context"
	"fmt"
	"os"

	"dagger.io/dagger"
)

func main() {
	ctx := context.Background()
	fmt.Println("Connecting")
	d, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
	if err != nil {
		panic(err)
	}

	fmt.Println("Getting EnvVariables from nginx:1.23.2")
	nginx := d.Container().From("nginx:1.23.2")

	vars, err := nginx.EnvVariables(ctx)
	if err != nil {
		fmt.Println(err)
	}

	fmt.Println("Printing", len(vars), "environment variables")
	for _, env := range vars {
		name, err := env.Name(ctx)
		if err != nil {
			panic(err)
		}
		val, err := env.Value(ctx)
		if err != nil {
			panic(err)
		}
		fmt.Println(name, "=", val)
	}
}

My understanding (via @aluzzardi) is that the client shouldn't be returning []EnvVariable.

Log output

$ go run ./cmd/dagger/main.go
Connecting
Getting EnvVariables from nginx:1.23.2
input:1: Field "envVariables" of type "[EnvVariable!]!" must have a sub selection.

Please visit https://dagger.io/help#go for troubleshooting guidance.
Printing 0 environment variables

Steps to reproduce

Run the attached program.

Dagger version

v0.4.1-0.20221115125729-579ada95545d

OS version

MacOS 12.6

Activity

  1. added
    kind/bug
    on Nov 15, 2022
  2. sipsma commented on Nov 15, 2022

    @sipsma
    Contributor

    RE: how we can fix this. @aluzzardi mentioned not allowing objects in lists in Discord (at least that was my understanding, correct me if wrong).

    If we are willing to trade more complexity for having the ability to return objects in lists maybe we could figure something out around autoselecting all trivial scalars for those cases, though I don't know if we'll have to apply that fix on a case-by-case basis (ugly) or if there's a way of cleanly generalizing it. Vague idea, might be a deadend, but in general it would be nice to support these return types.

  3. jlongtine commented on Nov 15, 2022

    @jlongtine
    ContributorAuthor

    I like that idea, as well, @sipsma. It'd make using the SDK even easier.

  4. helderco commented on Nov 15, 2022

    @helderco
    Contributor

    Duplicate of #3457

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions