status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
timestamp[us, tz=UTC] | language
stringclasses 5
values | commit_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | dagger/dagger | https://github.com/dagger/dagger | 6,358 | CLI: improve display of core API in `--help` output | https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`.
There's most likely going to be a lot of little things needed to address this, possibly including but not limited to:
1. displaying multi-line doc strings better
2. sorting of functions more cleanly
I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though. | https://github.com/dagger/dagger/issues/6358 | https://github.com/dagger/dagger/pull/6549 | 7a63c3d019530d1f08b2f72cc28e753d99b5896d | 7c0ee45d762719005fad5981d41b038811ebb7f6 | 2024-01-03T20:03:17Z | go | 2024-02-01T14:32:43Z | cmd/dagger/query.go | rec := progrock.FromContext(ctx)
vtx := rec.Vertex("query", "query", progrock.Focused())
defer func() { vtx.Done(rerr) }()
res, err := runQuery(ctx, engineClient, args)
if err != nil {
return err
}
result, err := json.MarshalIndent(res, "", " ")
if err != nil {
return err
}
var out io.Writer
if !term.IsTerminal(int(os.Stdout.Fd())) {
out = os.Stdout
} else {
out = vtx.Stdout()
}
fmt.Fprintf(out, "%s\n", result)
return nil
}
func runQuery( |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,358 | CLI: improve display of core API in `--help` output | https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`.
There's most likely going to be a lot of little things needed to address this, possibly including but not limited to:
1. displaying multi-line doc strings better
2. sorting of functions more cleanly
I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though. | https://github.com/dagger/dagger/issues/6358 | https://github.com/dagger/dagger/pull/6549 | 7a63c3d019530d1f08b2f72cc28e753d99b5896d | 7c0ee45d762719005fad5981d41b038811ebb7f6 | 2024-01-03T20:03:17Z | go | 2024-02-01T14:32:43Z | cmd/dagger/query.go | ctx context.Context,
engineClient *client.Client,
args []string,
) (map[string]any, error) {
var operation string
if len(args) > 0 {
operation = args[0]
}
vars := make(map[string]interface{})
if len(queryVarsJSONInput) > 0 {
if err := json.Unmarshal([]byte(queryVarsJSONInput), &vars); err != nil {
return nil, err
}
} else {
vars = getKVInput(queryVarsInput) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,358 | CLI: improve display of core API in `--help` output | https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`.
There's most likely going to be a lot of little things needed to address this, possibly including but not limited to:
1. displaying multi-line doc strings better
2. sorting of functions more cleanly
I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though. | https://github.com/dagger/dagger/issues/6358 | https://github.com/dagger/dagger/pull/6549 | 7a63c3d019530d1f08b2f72cc28e753d99b5896d | 7c0ee45d762719005fad5981d41b038811ebb7f6 | 2024-01-03T20:03:17Z | go | 2024-02-01T14:32:43Z | cmd/dagger/query.go | }
var operations string
if queryFile != "" {
inBytes, err := os.ReadFile(queryFile)
if err != nil {
return nil, err
}
operations = string(inBytes)
} else if !term.IsTerminal(int(os.Stdin.Fd())) {
inBytes, err := io.ReadAll(os.Stdin)
if err != nil {
return nil, err
}
operations = string(inBytes)
}
res := make(map[string]interface{})
err := engineClient.Do(ctx, operations, operation, vars, &res)
return res, err
}
func getKVInput(kvs []string) map[string]interface{} {
m := make(map[string]interface{})
for _, kv := range kvs {
split := strings.SplitN(kv, "=", 2)
m[split[0]] = split[1]
}
return m
}
func init() { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,358 | CLI: improve display of core API in `--help` output | https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`.
There's most likely going to be a lot of little things needed to address this, possibly including but not limited to:
1. displaying multi-line doc strings better
2. sorting of functions more cleanly
I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though. | https://github.com/dagger/dagger/issues/6358 | https://github.com/dagger/dagger/pull/6549 | 7a63c3d019530d1f08b2f72cc28e753d99b5896d | 7c0ee45d762719005fad5981d41b038811ebb7f6 | 2024-01-03T20:03:17Z | go | 2024-02-01T14:32:43Z | cmd/dagger/query.go | queryCmd.SetUsageTemplate(`Usage:{{if .Runnable}}
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
Aliases:
{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}}{{$cmds := .Commands}}{{if eq (len .Groups) 0}}
Available Commands:{{range $cmds}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{else}}{{range $group := .Groups}}
{{.Title}}{{range $cmds}}{{if (and (eq .GroupID $group.ID) (or .IsAvailableCommand (eq .Name "help")))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if not .AllChildCommandsHaveGroup}}
Additional Commands:{{range $cmds}}{{if (and (eq .GroupID "") (or .IsAvailableCommand (eq .Name "help")))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}{{if .HasExample}}
Examples:
{{.Example}}{{end}}
Global Flags:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`)
queryCmd.Flags().StringVar(&queryFile, "doc", "", "Read query from file (defaults to reading from stdin)")
queryCmd.Flags().StringSliceVar(&queryVarsInput, "var", nil, "List of query variables, in key=value format")
queryCmd.Flags().StringVar(&queryVarsJSONInput, "var-json", "", "Query variables in JSON format (overrides --var)")
queryCmd.MarkFlagFilename("doc", "graphql", "gql")
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,358 | CLI: improve display of core API in `--help` output | https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`.
There's most likely going to be a lot of little things needed to address this, possibly including but not limited to:
1. displaying multi-line doc strings better
2. sorting of functions more cleanly
I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though. | https://github.com/dagger/dagger/issues/6358 | https://github.com/dagger/dagger/pull/6549 | 7a63c3d019530d1f08b2f72cc28e753d99b5896d | 7c0ee45d762719005fad5981d41b038811ebb7f6 | 2024-01-03T20:03:17Z | go | 2024-02-01T14:32:43Z | cmd/dagger/run.go | package main
import (
"context"
"errors"
"fmt"
"net"
"net/http"
"os"
"os/exec"
"strings"
"time"
"github.com/dagger/dagger/engine/client"
"github.com/dagger/dagger/internal/tui"
"github.com/google/uuid"
"github.com/spf13/cobra"
"github.com/vito/progrock"
)
var runCmd = &cobra.Command{
Use: "run [flags] COMMAND",
Aliases: []string{"r"},
Short: "Run a command in a Dagger session", |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,358 | CLI: improve display of core API in `--help` output | https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`.
There's most likely going to be a lot of little things needed to address this, possibly including but not limited to:
1. displaying multi-line doc strings better
2. sorting of functions more cleanly
I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though. | https://github.com/dagger/dagger/issues/6358 | https://github.com/dagger/dagger/pull/6549 | 7a63c3d019530d1f08b2f72cc28e753d99b5896d | 7c0ee45d762719005fad5981d41b038811ebb7f6 | 2024-01-03T20:03:17Z | go | 2024-02-01T14:32:43Z | cmd/dagger/run.go | Long: strings.ReplaceAll(
`Executes the specified command in a Dagger Session and displays
live progress in a TUI.
´DAGGER_SESSION_PORT´ and ´DAGGER_SESSION_TOKEN´ will be convieniently
injected automatically.
For example:
´´´shell
jq -n '{query:"{container{id}}"}' | \
dagger run sh -c 'curl -s \
-u $DAGGER_SESSION_TOKEN: \
-H "content-type:application/json" \
-d @- \
http://127.0.0.1:$DAGGER_SESSION_PORT/query
´´´`,
"´",
"`",
),
Example: strings.TrimSpace(`
dagger run go run main.go
dagger run node index.mjs
dagger run python main.py
`,
),
Run: Run,
Args: cobra.MinimumNArgs(1),
SilenceUsage: true,
}
var waitDelay time.Duration
var runFocus bool
func init() { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,358 | CLI: improve display of core API in `--help` output | https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`.
There's most likely going to be a lot of little things needed to address this, possibly including but not limited to:
1. displaying multi-line doc strings better
2. sorting of functions more cleanly
I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though. | https://github.com/dagger/dagger/issues/6358 | https://github.com/dagger/dagger/pull/6549 | 7a63c3d019530d1f08b2f72cc28e753d99b5896d | 7c0ee45d762719005fad5981d41b038811ebb7f6 | 2024-01-03T20:03:17Z | go | 2024-02-01T14:32:43Z | cmd/dagger/run.go | // don't require -- to disambiguate subcommand flags
runCmd.Flags().SetInterspersed(false)
runCmd.Flags().DurationVar(
&waitDelay,
"cleanup-timeout",
10*time.Second,
"max duration to wait between SIGTERM and SIGKILL on interrupt",
)
runCmd.Flags().BoolVar(&runFocus, "focus", false, "Only show output for focused commands.")
}
func Run(cmd *cobra.Command, args []string) {
ctx := context.Background()
err := run(ctx, args)
if err != nil {
if errors.Is(err, context.Canceled) {
fmt.Fprintln(os.Stderr, "run canceled")
os.Exit(2)
return
}
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
return
}
}
func run(ctx context.Context, args []string) error { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,358 | CLI: improve display of core API in `--help` output | https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`.
There's most likely going to be a lot of little things needed to address this, possibly including but not limited to:
1. displaying multi-line doc strings better
2. sorting of functions more cleanly
I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though. | https://github.com/dagger/dagger/issues/6358 | https://github.com/dagger/dagger/pull/6549 | 7a63c3d019530d1f08b2f72cc28e753d99b5896d | 7c0ee45d762719005fad5981d41b038811ebb7f6 | 2024-01-03T20:03:17Z | go | 2024-02-01T14:32:43Z | cmd/dagger/run.go | u, err := uuid.NewRandom()
if err != nil {
return fmt.Errorf("generate uuid: %w", err)
}
sessionToken := u.String()
focus = runFocus
return withEngineAndTUI(ctx, client.Params{
SecretToken: sessionToken,
}, func(ctx context.Context, engineClient *client.Client) error {
sessionL, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
return fmt.Errorf("session listen: %w", err)
}
defer sessionL.Close()
sessionPort := fmt.Sprintf("%d", sessionL.Addr().(*net.TCPAddr).Port)
os.Setenv("DAGGER_SESSION_PORT", sessionPort)
os.Setenv("DAGGER_SESSION_TOKEN", sessionToken)
subCmd := exec.CommandContext(ctx, args[0], args[1:]...) // #nosec
w piping to the command
subCmd.Stdin = os.Stdin
// NB: go run lets its child process roam free when you interrupt it, so |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,358 | CLI: improve display of core API in `--help` output | https://github.com/dagger/dagger/pull/6293 exposed the core API in `dagger call`, which results in `--help` and `dagger functions` output to be pretty overwhelming and messy when dealing with core types like `Container`.
There's most likely going to be a lot of little things needed to address this, possibly including but not limited to:
1. displaying multi-line doc strings better
2. sorting of functions more cleanly
I think we should start out trying to do this purely from the CLI without engine-side changes. But if that ends up not being feasible then we can consider whether typedefs could get optional support for annotating CLI specific presentation metadata. Preferable to avoid going down that road if possible though. | https://github.com/dagger/dagger/issues/6358 | https://github.com/dagger/dagger/pull/6549 | 7a63c3d019530d1f08b2f72cc28e753d99b5896d | 7c0ee45d762719005fad5981d41b038811ebb7f6 | 2024-01-03T20:03:17Z | go | 2024-02-01T14:32:43Z | cmd/dagger/run.go | // make sure they all get signalled. (you don't normally notice this in a
// shell because Ctrl+C sends to the process group.)
ensureChildProcessesAreKilled(subCmd)
go http.Serve(sessionL, engineClient) //nolint:gosec
var cmdErr error
if !silent {
rec := progrock.FromContext(ctx)
cmdline := strings.Join(subCmd.Args, " ")
cmdVtx := rec.Vertex(tui.RootVertex, cmdline)
if stdoutIsTTY {
subCmd.Stdout = cmdVtx.Stdout()
} else {
subCmd.Stdout = os.Stdout
}
if stderrIsTTY {
subCmd.Stderr = cmdVtx.Stderr()
} else {
subCmd.Stderr = os.Stderr
}
cmdErr = subCmd.Run()
cmdVtx.Done(cmdErr)
} else {
subCmd.Stdout = os.Stdout
subCmd.Stderr = os.Stderr
cmdErr = subCmd.Run()
}
return cmdErr
})
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/module_funcs.go | package templates
import (
"encoding/json"
"fmt"
"go/types"
"maps"
"strconv"
"strings" |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/module_funcs.go | . "github.com/dave/jennifer/jen"
)
const errorTypeName = "error"
var voidDef = Qual("dag", "TypeDef").Call().
Dot("WithKind").Call(Id("VoidKind")).
Dot("WithOptional").Call(Lit(true))
func (ps *parseState) parseGoFunc(parentType *types.Named, fn *types.Func) (*funcTypeSpec, error) {
spec := &funcTypeSpec{
name: fn.Name(),
}
funcDecl, err := ps.declForFunc(parentType, fn)
if err != nil {
return nil, fmt.Errorf("failed to find decl for method %s: %w", fn.Name(), err)
}
spec.doc = funcDecl.Doc.Text()
sig, ok := fn.Type().(*types.Signature)
if !ok {
return nil, fmt.Errorf("expected method to be a func, got %T", fn.Type())
}
spec.goType = sig
spec.argSpecs, err = ps.parseParamSpecs(parentType, fn)
if err != nil {
return nil, err
}
if parentType != nil {
if _, ok := parentType.Underlying().(*types.Struct); ok {
receiverTypeName := parentType.Obj().Name() |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/module_funcs.go | ps.methods[receiverTypeName] = append(ps.methods[receiverTypeName], method{fn: fn, paramSpecs: spec.argSpecs})
}
}
results := sig.Results()
switch results.Len() {
case 0:
case 1:
result := results.At(0).Type()
if result.String() == errorTypeName {
spec.returnsError = true
break
}
spec.returnSpec, err = ps.parseGoTypeReference(result, nil, false)
if err != nil {
return nil, fmt.Errorf("failed to parse return type: %w", err)
}
case 2:
spec.returnsError = true
result := results.At(0).Type()
spec.returnSpec, err = ps.parseGoTypeReference(result, nil, false)
if err != nil {
return nil, fmt.Errorf("failed to parse return type: %w", err)
}
default:
return nil, fmt.Errorf("method %s has too many return values", fn.Name())
}
return spec, nil
}
type funcTypeSpec struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/module_funcs.go | name string
doc string
argSpecs []paramSpec
returnSpec ParsedType
returnsError bool
goType *types.Signature
}
var _ ParsedType = &funcTypeSpec{}
func (spec *funcTypeSpec) TypeDefCode() (*Statement, error) {
var fnReturnTypeDefCode *Statement
if spec.returnSpec == nil {
fnReturnTypeDefCode = voidDef
} else {
var err error
fnReturnTypeDefCode, err = spec.returnSpec.TypeDefCode()
if err != nil {
return nil, fmt.Errorf("failed to generate return type code: %w", err)
}
}
fnTypeDefCode := Qual("dag", "Function").Call(Lit(spec.name), Add(Line(), fnReturnTypeDefCode))
if spec.doc != "" {
fnTypeDefCode = dotLine(fnTypeDefCode, "WithDescription").Call(Lit(strings.TrimSpace(spec.doc)))
}
for i, argSpec := range spec.argSpecs {
if i == 0 && argSpec.paramType.String() == contextTypename {
continue
}
argTypeDefCode, err := argSpec.typeSpec.TypeDefCode()
if err != nil { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/module_funcs.go | return nil, fmt.Errorf("failed to generate arg type code: %w", err)
}
if argSpec.optional {
argTypeDefCode = argTypeDefCode.Dot("WithOptional").Call(Lit(true))
}
argOptsCode := []Code{}
if argSpec.description != "" {
argOptsCode = append(argOptsCode, Id("Description").Op(":").Lit(argSpec.description))
}
if argSpec.defaultValue != "" {
var jsonEnc string
if argSpec.typeSpec.GoType().String() == "string" {
enc, err := json.Marshal(argSpec.defaultValue)
if err != nil {
return nil, fmt.Errorf("failed to marshal default value: %w", err)
}
jsonEnc = string(enc)
} else {
jsonEnc = argSpec.defaultValue
}
argOptsCode = append(argOptsCode, Id("DefaultValue").Op(":").Id("JSON").Call(Lit(jsonEnc)))
}
argTypeDefArgCode := []Code{Lit(argSpec.name), argTypeDefCode}
if len(argOptsCode) > 0 {
argTypeDefArgCode = append(argTypeDefArgCode, Id("FunctionWithArgOpts").Values(argOptsCode...))
}
fnTypeDefCode = dotLine(fnTypeDefCode, "WithArg").Call(argTypeDefArgCode...)
}
return fnTypeDefCode, nil |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/module_funcs.go | }
func (spec *funcTypeSpec) GoType() types.Type {
return spec.goType
}
func (spec *funcTypeSpec) GoSubTypes() []types.Type {
var types []types.Type
if spec.returnSpec != nil {
types = append(types, spec.returnSpec.GoSubTypes()...)
}
for _, argSpec := range spec.argSpecs {
if argSpec.typeSpec == nil {
continue
}
types = append(types, argSpec.typeSpec.GoSubTypes()...)
}
return types
}
func (ps *parseState) parseParamSpecs(parentType *types.Named, fn *types.Func) ([]paramSpec, error) {
sig := fn.Type().(*types.Signature)
params := sig.Params()
if params.Len() == 0 {
return nil, nil
}
specs := make([]paramSpec, 0, params.Len())
i := 0
if params.At(i).Type().String() == contextTypename {
spec, err := ps.parseParamSpecVar(params.At(i), "", "")
if err != nil {
return nil, err |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/module_funcs.go | }
specs = append(specs, spec)
i++
}
fnDecl, err := ps.declForFunc(parentType, fn)
if err != nil {
return nil, err
}
if i+1 == params.Len() {
param := params.At(i)
paramType, ok := asInlineStruct(param.Type())
if ok {
stype, ok := asInlineStructAst(fnDecl.Type.Params.List[i].Type)
if !ok {
return nil, fmt.Errorf("expected struct type for %s", param.Name())
}
parent := ¶mSpec{
name: params.At(i).Name(),
paramType: param.Type(),
}
paramFields := unpackASTFields(stype.Fields)
for f := 0; f < paramType.NumFields(); f++ {
spec, err := ps.parseParamSpecVar(paramType.Field(f), paramFields[f].Doc.Text(), paramFields[f].Comment.Text())
if err != nil {
return nil, err
}
spec.parent = parent
specs = append(specs, spec) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/module_funcs.go | }
return specs, nil
}
}
paramFields := unpackASTFields(fnDecl.Type.Params)
for ; i < params.Len(); i++ {
docComment, lineComment := ps.commentForFuncField(fnDecl, paramFields, i)
spec, err := ps.parseParamSpecVar(params.At(i), docComment.Text(), lineComment.Text())
if err != nil {
return nil, err
}
if sig.Variadic() && i == params.Len()-1 {
spec.variadic = true
}
specs = append(specs, spec)
}
return specs, nil
}
func (ps *parseState) parseParamSpecVar(field *types.Var, docComment string, lineComment string) (paramSpec, error) {
if _, ok := field.Type().(*types.Struct); ok {
return paramSpec{}, fmt.Errorf("nested structs are not supported")
}
paramType := field.Type()
baseType := paramType
isPtr := false
for {
ptr, ok := baseType.(*types.Pointer)
if !ok { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/module_funcs.go | break
}
isPtr = true
baseType = ptr.Elem()
}
optional := false
defaultValue := ""
wrappedType, isOptionalType, err := ps.isOptionalWrapper(baseType)
if err != nil {
return paramSpec{}, fmt.Errorf("failed to check if type is optional: %w", err)
}
if isOptionalType {
optional = true
baseType = wrappedType
isPtr = false
for {
ptr, ok := baseType.(*types.Pointer)
if !ok {
break
}
isPtr = true
baseType = ptr.Elem()
}
}
docPragmas, docComment := parsePragmaComment(docComment)
linePragmas, lineComment := parsePragmaComment(lineComment)
comment := strings.TrimSpace(docComment)
if comment == "" {
comment = strings.TrimSpace(lineComment)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/module_funcs.go | pragmas := make(map[string]string)
maps.Copy(pragmas, docPragmas)
maps.Copy(pragmas, linePragmas)
if v, ok := pragmas["default"]; ok {
defaultValue = v
}
if v, ok := pragmas["optional"]; ok {
if v == "" {
optional = true
} else {
optional, _ = strconv.ParseBool(v)
}
}
isContext := paramType.String() == contextTypename
var typeSpec ParsedType
if !isContext {
var err error
typeSpec, err = ps.parseGoTypeReference(baseType, nil, isPtr)
if err != nil {
return paramSpec{}, fmt.Errorf("failed to parse type reference: %w", err)
}
}
name := field.Name()
if name == "" && typeSpec != nil {
name = typeSpec.GoType().String()
}
return paramSpec{
name: name, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/module_funcs.go | paramType: paramType,
typeSpec: typeSpec,
optional: optional,
hasOptionalWrapper: isOptionalType,
isContext: isContext,
defaultValue: defaultValue,
description: comment,
}, nil
}
type paramSpec struct {
name string
description string
optional bool
variadic bool
hasOptionalWrapper bool
isContext bool
defaultValue string
paramType types.Type
typeSpec ParsedType
parent *paramSpec
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | package templates
import (
"fmt"
"go/ast"
"go/token"
"go/types"
"os"
"path/filepath"
"regexp"
"runtime/debug"
"sort"
"strings"
. "github.com/dave/jennifer/jen"
"github.com/iancoleman/strcase"
"golang.org/x/tools/go/packages"
) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | const (
daggerGenFilename = "dagger.gen.go"
contextTypename = "context.Context"
constructorFuncName = "New"
daggerObjectIfaceName = "DaggerObject"
)
func (funcs goTemplateFuncs) isModuleCode() bool {
return funcs.moduleName != ""
}
/*
moduleMainSrc generates the source code of the main func for Dagger Module code using the Go SDK.
The overall idea is that users just need to create a struct with the same name as their Module and then
add methods to that struct to implement their Module. Methods on that struct become Functions.
They are also free to return custom objects from Functions, which themselves may have methods that become
Functions too. However, only the "top-level" Module struct's Functions will be directly invokable.
This is essentially just the GraphQL execution model.
The implementation works by parsing the user's code and generating a main func that reads function call inputs
from the Engine, calls the relevant function and returns the result. The generated code is mostly a giant switch/case
on the object+function name, with each case doing json deserialization of the input arguments and calling the actual
Go function.
*/
func (funcs goTemplateFuncs) moduleMainSrc() (string, error) {
defer func() {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "internal error during module code generation: %v\n", r)
debug.PrintStack()
panic(r) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | }
}()
if funcs.modulePkg == nil {
return `func main() { panic("no code yet") }`, nil
}
ps := &parseState{
pkg: funcs.modulePkg,
fset: funcs.moduleFset,
methods: make(map[string][]method),
moduleName: funcs.moduleName,
}
pkgScope := funcs.modulePkg.Types.Scope()
objFunctionCases := map[string][]Code{}
createMod := Qual("dag", "Module").Call()
objs := []types.Object{}
for _, name := range pkgScope.Names() {
obj := pkgScope.Lookup(name)
if obj == nil {
continue
}
objs = append(objs, obj)
}
sort.Slice(objs, func(i, j int) bool {
return objs[i].Pos() < objs[j].Pos()
})
tps := []types.Type{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | for _, obj := range objs {
if ok := ps.checkConstructor(obj); ok {
continue
}
if ok := ps.checkDaggerObjectIface(obj); ok {
continue
}
if ps.isMainModuleObject(obj.Name()) || ps.isDaggerGenerated(obj) {
tps = append(tps, obj.Type())
}
}
if ps.daggerObjectIfaceType == nil {
return "", fmt.Errorf("cannot find default codegen %s interface", daggerObjectIfaceName)
}
added := map[string]struct{}{}
implementationCode := Empty()
for len(tps) != 0 {
var nextTps []types.Type
for _, tp := range tps {
named, isNamed := tp.(*types.Named)
if !isNamed {
continue
}
obj := named.Obj()
if obj.Pkg() != funcs.modulePkg.Types {
continue
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | if !obj.Exported() {
return "", fmt.Errorf("cannot code-generate unexported type %s", obj.Name())
}
if _, ok := added[obj.Name()]; ok {
continue
}
switch underlyingObj := named.Underlying().(type) {
case *types.Struct:
strct := underlyingObj
objTypeSpec, err := ps.parseGoStruct(strct, named)
if err != nil {
return "", err
}
if objTypeSpec == nil {
continue
}
if err := ps.fillObjectFunctionCases(named, objFunctionCases); err != nil {
return "", fmt.Errorf("failed to generate function cases for %s: %w", obj.Name(), err)
}
objTypeDefCode, err := objTypeSpec.TypeDefCode()
if err != nil {
return "", fmt.Errorf("failed to generate type def code for %s: %w", obj.Name(), err)
}
createMod = dotLine(createMod, "WithObject").Call(Add(Line(), objTypeDefCode))
added[obj.Name()] = struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | implCode, err := objTypeSpec.ImplementationCode()
if err != nil {
return "", fmt.Errorf("failed to generate json method code for %s: %w", obj.Name(), err)
}
implementationCode.Add(implCode).Line()
nextTps = append(nextTps, objTypeSpec.GoSubTypes()...)
case *types.Interface:
iface := underlyingObj
ifaceTypeSpec, err := ps.parseGoIface(iface, named)
if err != nil {
return "", err
}
if ifaceTypeSpec == nil {
continue
}
ifaceTypeDefCode, err := ifaceTypeSpec.TypeDefCode()
if err != nil {
return "", fmt.Errorf("failed to generate type def code for %s: %w", obj.Name(), err)
}
createMod = dotLine(createMod, "WithInterface").Call(Add(Line(), ifaceTypeDefCode))
added[obj.Name()] = struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | implCode, err := ifaceTypeSpec.ImplementationCode()
if err != nil {
return "", fmt.Errorf("failed to generate concrete struct code for %s: %w", obj.Name(), err)
}
implementationCode.Add(implCode).Line()
nextTps = append(nextTps, ifaceTypeSpec.GoSubTypes()...)
}
}
tps, nextTps = nextTps, nil
}
return strings.Join([]string{
fmt.Sprintf("%#v", implementationCode),
mainSrc,
invokeSrc(objFunctionCases, createMod),
}, "\n"), nil
}
func dotLine(a *Statement, id string) *Statement { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | return a.Op(".").Line().Id(id)
}
const (
mainSrc = `func main() {
ctx := context.Background()
fnCall := dag.CurrentFunctionCall()
parentName, err := fnCall.ParentName(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
fnName, err := fnCall.Name(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
parentJson, err := fnCall.Parent(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
fnArgs, err := fnCall.InputArgs(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
inputArgs := map[string][]byte{}
for _, fnArg := range fnArgs { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | argName, err := fnArg.Name(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
argValue, err := fnArg.Value(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
inputArgs[argName] = []byte(argValue)
}
result, err := invoke(ctx, []byte(parentJson), parentName, fnName, inputArgs)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
resultBytes, err := json.Marshal(result)
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
_, err = fnCall.ReturnValue(ctx, JSON(resultBytes))
if err != nil {
fmt.Println(err.Error())
os.Exit(2)
}
}
`
parentJSONVar = "parentJSON" |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | parentNameVar = "parentName"
fnNameVar = "fnName"
inputArgsVar = "inputArgs"
invokeFuncName = "invoke"
)
func invokeSrc(objFunctionCases map[string][]Code, createMod Code) string {
objCases := []Code{}
for objName, functionCases := range objFunctionCases {
objCases = append(objCases, Case(Lit(objName)).Block(Switch(Id(fnNameVar)).Block(functionCases...)))
}
objCases = append(objCases, Case(Lit("")).Block(
Return(createMod, Nil()),
))
objCases = append(objCases, Default().Block(
Return(Nil(), Qual("fmt", "Errorf").Call(Lit("unknown object %s"), Id(parentNameVar))),
))
objSwitch := Switch(Id(parentNameVar)).Block(objCases...)
invokeFunc := Func().Id(invokeFuncName).Params(
Id("ctx").Qual("context", "Context"),
Id(parentJSONVar).Index().Byte(),
Id(parentNameVar).String(),
Id(fnNameVar).String(), |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | Id(inputArgsVar).Map(String()).Index().Byte(),
).Params(
Id("_").Id("any"),
Id("err").Error(),
).Block(objSwitch)
return fmt.Sprintf("%#v", invokeFunc)
}
func renderNameOrStruct(t types.Type) string {
if ptr, ok := t.(*types.Pointer); ok {
return "*" + renderNameOrStruct(ptr.Elem())
}
if sl, ok := t.(*types.Slice); ok {
return "[]" + renderNameOrStruct(sl.Elem())
}
if st, ok := t.(*types.Struct); ok {
result := "struct {\n"
for i := 0; i < st.NumFields(); i++ {
if !st.Field(i).Embedded() {
result += st.Field(i).Name() + " "
}
result += renderNameOrStruct(st.Field(i).Type())
if tag := st.Tag(i); tag != "" {
result += " `" + tag + "`"
}
result += "\n"
}
result += "}" |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | return result
}
if named, ok := t.(*types.Named); ok {
if _, ok := named.Underlying().(*types.Interface); ok {
return "*" + formatIfaceImplName(named.Obj().Name())
}
base := named.Obj().Name()
if typeArgs := named.TypeArgs(); typeArgs.Len() > 0 {
base += "["
for i := 0; i < typeArgs.Len(); i++ {
if i > 0 {
base += ", "
}
base += renderNameOrStruct(typeArgs.At(i))
}
base += "]"
}
return base
}
return t.String()
}
func checkErrStatement(label string) *Statement { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | return If(Err().Op("!=").Nil()).Block(
Id("panic").Call(Qual("fmt", "Errorf").Call(Lit("%s: %w"), Lit(label), Err())),
)
}
func (ps *parseState) checkConstructor(obj types.Object) bool {
fn, isFn := obj.(*types.Func)
if !isFn {
return false
}
if fn.Name() != constructorFuncName {
return false
}
ps.constructor = fn
return true
}
func (ps *parseState) checkDaggerObjectIface(obj types.Object) bool {
named, isNamed := obj.Type().(*types.Named)
if !isNamed {
return false
}
iface, isIface := named.Underlying().(*types.Interface) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | if !isIface {
return false
}
if named.Obj().Name() != daggerObjectIfaceName {
return false
}
ps.daggerObjectIfaceType = iface
return true
}
func (ps *parseState) fillObjectFunctionCases(type_ types.Type, cases map[string][]Code) error {
var objName string
switch x := type_.(type) {
case *types.Pointer:
return ps.fillObjectFunctionCases(x.Elem(), cases)
case *types.Named:
objName = x.Obj().Name()
default:
return nil
}
if existingCases := cases[objName]; len(existingCases) > 0 {
return nil
}
hasConstructor := ps.isMainModuleObject(objName) && ps.constructor != nil
methods := ps.methods[objName]
if len(methods) == 0 && !hasConstructor {
return nil
}
for _, method := range methods {
fnName, sig := method.fn.Name(), method.fn.Type().(*types.Signature) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | if err := ps.fillObjectFunctionCase(objName, fnName, fnName, sig, method.paramSpecs, cases); err != nil {
return err
}
}
if hasConstructor {
sig, ok := ps.constructor.Type().(*types.Signature)
if !ok {
return fmt.Errorf("expected %s to be a function, got %T", constructorFuncName, ps.constructor.Type())
}
paramSpecs, err := ps.parseParamSpecs(nil, ps.constructor)
if err != nil {
return fmt.Errorf("failed to parse %s function: %w", constructorFuncName, err)
}
results := sig.Results()
if results.Len() == 0 {
return fmt.Errorf("%s must return a value", constructorFuncName)
}
resultType := results.At(0).Type()
if ptrType, ok := resultType.(*types.Pointer); ok {
resultType = ptrType.Elem()
}
namedType, ok := resultType.(*types.Named)
if !ok {
return fmt.Errorf("%s must return the main module object %q", constructorFuncName, objName)
}
if namedType.Obj().Name() != objName {
return fmt.Errorf("%s must return the main module object %q", constructorFuncName, objName)
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | if err := ps.fillObjectFunctionCase(objName, ps.constructor.Name(), "", sig, paramSpecs, cases); err != nil {
return err
}
}
cases[objName] = append(cases[objName], Default().Block(
Return(Nil(), Qual("fmt", "Errorf").Call(Lit("unknown function %s"), Id(fnNameVar))),
))
return nil
}
func (ps *parseState) fillObjectFunctionCase(
objName string,
fnName string,
caseName string,
sig *types.Signature,
paramSpecs []paramSpec,
cases map[string][]Code,
) error {
statements := []Code{}
parentVarName := "parent"
statements = append(statements,
Var().Id(parentVarName).Id(objName),
Err().Op("=").Qual("json", "Unmarshal").Call(Id(parentJSONVar), Op("&").Id(parentVarName)),
checkErrStatement("failed to unmarshal parent object"),
)
var fnCallArgs []Code
if sig.Recv() != nil {
fnCallArgs = []Code{Op("&").Id(parentVarName)}
}
vars := map[string]struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | for i, spec := range paramSpecs {
if i == 0 && spec.paramType.String() == contextTypename {
fnCallArgs = append(fnCallArgs, Id("ctx"))
continue
}
var varName string
var varType types.Type
var target *Statement
if spec.parent == nil {
varName = strcase.ToLowerCamel(spec.name)
varType = spec.paramType
target = Id(varName)
} else {
varName = spec.parent.name
varType = spec.parent.paramType
target = Id(spec.parent.name).Dot(spec.name)
}
if _, ok := vars[varName]; !ok {
vars[varName] = struct{}{} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | tp := varType
fnCallArgCode := Id(varName)
tp2, fnCallArgCode2, ok, err := ps.functionCallArgCode(varType, Id(varName))
if err != nil {
return fmt.Errorf("failed to get function call arg code for %s: %w", varName, err)
}
if ok {
tp = tp2
fnCallArgCode = fnCallArgCode2
}
statements = append(statements, Var().Id(varName).Id(renderNameOrStruct(tp)))
if spec.variadic {
fnCallArgs = append(fnCallArgs, fnCallArgCode.Op("..."))
} else {
fnCallArgs = append(fnCallArgs, fnCallArgCode) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | }
}
statements = append(statements,
If(Id(inputArgsVar).Index(Lit(spec.name)).Op("!=").Nil()).Block(
Err().Op("=").Qual("json", "Unmarshal").Call(
Index().Byte().Parens(Id(inputArgsVar).Index(Lit(spec.name))),
Op("&").Add(target),
),
checkErrStatement("failed to unmarshal input arg "+spec.name),
))
}
results := sig.Results()
var callStatement *Statement
if sig.Recv() != nil {
callStatement = Parens(Op("*").Id(objName)).Dot(fnName).Call(fnCallArgs...)
} else {
callStatement = Id(fnName).Call(fnCallArgs...)
}
switch results.Len() {
case 2:
if results.At(1).Type().String() != errorTypeName {
return fmt.Errorf("second return value must be error, have %s", results.At(1).Type().String())
}
statements = append(statements, Return(callStatement))
cases[objName] = append(cases[objName], Case(Lit(caseName)).Block(statements...))
if err := ps.fillObjectFunctionCases(results.At(0).Type(), cases); err != nil {
return err
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | return nil
case 1:
if results.At(0).Type().String() == errorTypeName {
statements = append(statements, Return(Nil(), callStatement))
cases[objName] = append(cases[objName], Case(Lit(caseName)).Block(statements...))
} else {
statements = append(statements, Return(callStatement, Nil()))
cases[objName] = append(cases[objName], Case(Lit(caseName)).Block(statements...))
if err := ps.fillObjectFunctionCases(results.At(0).Type(), cases); err != nil {
return err
}
}
return nil
case 0:
statements = append(statements,
callStatement,
Return(Nil(), Nil()))
cases[objName] = append(cases[objName], Case(Lit(caseName)).Block(statements...))
return nil
default:
return fmt.Errorf("unexpected number of results from function %s: %d", fnName, results.Len())
}
}
type parseState struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | pkg *packages.Package
fset *token.FileSet
methods map[string][]method
moduleName string
constructor *types.Func
daggerObjectIfaceType *types.Interface
}
func (ps *parseState) isMainModuleObject(name string) bool {
return strcase.ToCamel(ps.moduleName) == strcase.ToCamel(name)
}
type method struct {
fn *types.Func
paramSpecs []paramSpec
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | func (ps *parseState) astSpecForNamedType(namedType *types.Named) (*ast.TypeSpec, error) {
tokenFile := ps.fset.File(namedType.Obj().Pos())
if tokenFile == nil {
return nil, fmt.Errorf("no file for %s", namedType.Obj().Name())
}
for _, f := range ps.pkg.Syntax {
if ps.fset.File(f.Pos()) != tokenFile {
continue
}
for _, decl := range f.Decls {
genDecl, ok := decl.(*ast.GenDecl)
if !ok {
continue
}
for _, spec := range genDecl.Specs {
typeSpec, ok := spec.(*ast.TypeSpec)
if !ok {
continue
}
if typeSpec.Name.Name == namedType.Obj().Name() {
if typeSpec.Doc == nil {
typeSpec.Doc = genDecl.Doc
}
return typeSpec, nil
}
}
}
}
return nil, fmt.Errorf("no decl for %s", namedType.Obj().Name())
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | func (ps *parseState) declForFunc(parentType *types.Named, fnType *types.Func) (*ast.FuncDecl, error) {
var recv *types.Named
if signature, ok := fnType.Type().(*types.Signature); ok && signature.Recv() != nil {
tp := signature.Recv().Type()
for {
if p, ok := tp.(*types.Pointer); ok {
tp = p.Elem()
continue
}
break
}
recv, _ = tp.(*types.Named)
}
var underlying types.Type
if parentType != nil {
underlying = parentType.Underlying()
}
tokenFile := ps.fset.File(fnType.Pos())
if tokenFile == nil {
return nil, fmt.Errorf("no file for %s", fnType.Name())
}
for _, f := range ps.pkg.Syntax {
if ps.fset.File(f.Pos()) != tokenFile {
continue
}
for _, decl := range f.Decls {
switch underlying.(type) {
case *types.Struct, nil:
for _, decl := range f.Decls { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | fnDecl, ok := decl.(*ast.FuncDecl)
if !ok {
continue
}
if fnDecl.Name.Name != fnType.Name() {
continue
}
if recv != nil {
if len(fnDecl.Recv.List) != 1 {
continue
}
tp := fnDecl.Recv.List[0].Type
for {
if star, ok := tp.(*ast.StarExpr); ok {
tp = star.X
continue
}
break
}
ident, ok := tp.(*ast.Ident)
if !ok {
continue
}
if ident.Name != recv.Obj().Name() {
continue
}
}
return fnDecl, nil
}
case *types.Interface: |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | genDecl, ok := decl.(*ast.GenDecl)
if !ok {
continue
}
for _, spec := range genDecl.Specs {
typeSpec, ok := spec.(*ast.TypeSpec)
if !ok {
continue
}
if typeSpec.Name.Name != parentType.Obj().Name() {
continue
}
iface, ok := typeSpec.Type.(*ast.InterfaceType)
if !ok {
continue
}
for _, ifaceField := range iface.Methods.List {
ifaceFieldFunc, ok := ifaceField.Type.(*ast.FuncType)
if !ok {
continue
}
ifaceFieldFuncName := ifaceField.Names[0].Name
if ifaceFieldFuncName != fnType.Name() {
continue
}
return &ast.FuncDecl{
Doc: ifaceField.Doc,
Type: ifaceFieldFunc,
}, nil |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | }
}
}
}
}
return nil, fmt.Errorf("no decl for %s", fnType.Name())
}
func (ps *parseState) commentForFuncField(fnDecl *ast.FuncDecl, unpackedParams []*ast.Field, i int) (docComment *ast.CommentGroup, lineComment *ast.CommentGroup) {
pos := unpackedParams[i].Pos()
tokenFile := ps.fset.File(pos)
if tokenFile == nil {
return nil, nil
}
line := tokenFile.Line(pos)
allowDocComment := true
allowLineComment := true
if i == 0 {
fieldStartLine := tokenFile.Line(fnDecl.Type.Params.Pos())
if fieldStartLine == line || fieldStartLine == line-1 {
allowDocComment = false
}
} else {
prevArgLine := tokenFile.Line(unpackedParams[i-1].Pos())
if prevArgLine == line || prevArgLine == line-1 {
allowDocComment = false
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | }
if i+1 < len(fnDecl.Type.Params.List) {
nextArgLine := tokenFile.Line(unpackedParams[i+1].Pos())
if nextArgLine == line {
allowLineComment = false
}
} else {
fieldEndLine := tokenFile.Line(fnDecl.Type.Params.End())
if fieldEndLine == line {
allowLineComment = false
}
}
for _, f := range ps.pkg.Syntax {
if ps.fset.File(f.Pos()) != tokenFile {
continue
}
if allowDocComment {
npos := tokenFile.LineStart(tokenFile.Line(pos)) - 1
for _, comment := range f.Comments {
if comment.Pos() <= npos && npos <= comment.End() {
docComment = comment
break
}
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | }
if allowLineComment {
npos := tokenFile.LineStart(tokenFile.Line(pos)+1) - 1
for _, comment := range f.Comments {
if comment.Pos() <= npos && npos <= comment.End() {
lineComment = comment
break
}
}
}
}
return docComment, lineComment
}
func (ps *parseState) isDaggerGenerated(obj types.Object) bool {
tokenFile := ps.fset.File(obj.Pos())
return filepath.Base(tokenFile.Name()) == daggerGenFilename
}
func (ps *parseState) isOptionalWrapper(typ types.Type) (types.Type, bool, error) {
named, ok := typ.(*types.Named)
if !ok {
return nil, false, nil
}
if named.Obj().Name() != "Optional" || !ps.isDaggerGenerated(named.Obj()) {
return nil, false, nil
}
typeArgs := named.TypeArgs()
if typeArgs.Len() != 1 {
return nil, false, fmt.Errorf("optional type must have exactly one type argument") |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | }
return typeArgs.At(0), true, nil
}
/*
functionCallArgCode takes a type and code for providing an arg of that type (just
the name of the arg variable as a base) and returns the type that should be used
to declare the arg as well as the code that should be used to provide the arg
variable to a function call
This is needed to handle various special cases:
* Function args that are various degrees of pointeriness (i.e. *string, **int, etc.)
* Concrete structs implementing an interface that will be provided as an arg
* Slices and Optional wrappers of the above
*/
func (ps *parseState) functionCallArgCode(t types.Type, access *Statement) (types.Type, *Statement, bool, error) {
switch t := t.(type) {
case *types.Pointer:
t2, access2, ok, err := ps.functionCallArgCode(t.Elem(), access)
if err != nil {
return nil, nil, false, err
}
if ok {
/*
Taking the address of an address isn't allowed - so we use a ptr helper
function. e.g.:
ptr(access)
*/
return t2, Id("ptr").Call(access2), true, nil
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | return nil, nil, false, nil
case *types.Named:
wrappedType, isOptionalType, err := ps.isOptionalWrapper(t)
if err != nil {
return nil, nil, false, err
}
if isOptionalType {
wrappedNamed, ok := wrappedType.(*types.Named)
if !ok {
return t, access, true, nil
}
_, ok = wrappedNamed.Underlying().(*types.Interface)
if !ok {
return t, access, true, nil
}
/*
Need to convert concrete impl struct wrapped by Optional to interface wrapped
by Optional. e.g.:
convertOptionalVal(access, (*ifaceImpl).toIface)
*/
return t, Id("convertOptionalVal").Call(
access,
Parens(Op("*").Id(formatIfaceImplName(wrappedNamed.Obj().Name()))).Dot("toIface"),
), true, nil
}
if _, ok := t.Underlying().(*types.Interface); ok {
/*
Need to convert concrete impl struct interface. e.g.:
access.toIface |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | */
return t, access.Dot("toIface").Call(), true, nil
}
return nil, nil, false, nil
case *types.Slice:
elemNamed, ok := t.Elem().(*types.Named)
if !ok {
return nil, nil, false, nil
}
_, ok = elemNamed.Underlying().(*types.Interface)
if !ok {
return nil, nil, false, nil
}
/*
Need to convert slice of concrete impl structs to slice of interface e.g.:
convertSlice(access, (*ifaceImpl).toIface)
*/
return t, Id("convertSlice").Call(
access,
Parens(Op("*").Id(formatIfaceImplName(elemNamed.Obj().Name()))).Dot("toIface"),
), true, nil
case *types.Struct:
return t, access, true, nil
default:
return nil, nil, false, nil
}
}
var pragmaCommentRegexp = regexp.MustCompile(`\+\s*(\S+?)(?:=(.+))?(?:\n|$)`)
func parsePragmaComment(comment string) (data map[string]string, rest string) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | data = map[string]string{}
lastEnd := 0
for _, v := range pragmaCommentRegexp.FindAllStringSubmatchIndex(comment, -1) {
var key, value string
if v[2] != -1 {
key = comment[v[2]:v[3]]
}
if v[4] != -1 {
value = comment[v[4]:v[5]]
}
data[key] = value
rest += comment[lastEnd:v[0]]
lastEnd = v[1]
}
rest += comment[lastEnd:]
return data, rest
}
func asInlineStruct(t types.Type) (*types.Struct, bool) {
switch t := t.(type) {
case *types.Pointer:
return asInlineStruct(t.Elem())
case *types.Struct:
return t, true
default:
return nil, false
}
}
func asInlineStructAst(t ast.Node) (*ast.StructType, bool) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | cmd/codegen/generator/go/templates/modules.go | switch t := t.(type) {
case *ast.StarExpr:
return asInlineStructAst(t.X)
case *ast.StructType:
return t, true
default:
return nil, false
}
}
func unpackASTFields(fields *ast.FieldList) []*ast.Field {
var unpacked []*ast.Field
for _, field := range fields.List {
if len(field.Names) == 0 {
unpacked = append(unpacked, field)
continue
}
for i, name := range field.Names {
field := *field
field.Names = []*ast.Ident{name}
if i != 0 {
field.Doc = nil
field.Comment = nil
}
unpacked = append(unpacked, &field)
}
}
return unpacked
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | package core
import (
"context"
_ "embed"
"encoding/json"
"fmt"
"go/format"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"time"
"github.com/MakeNowJust/heredoc/v2"
"github.com/dagger/dagger/core/modules"
"github.com/dagger/dagger/dagql/idproto"
"github.com/iancoleman/strcase"
"github.com/moby/buildkit/identity"
"github.com/stretchr/testify/require"
"github.com/tidwall/gjson"
"golang.org/x/sync/errgroup"
"dagger.io/dagger"
"github.com/dagger/dagger/cmd/codegen/introspection"
)
func TestModuleGoInit(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | t.Parallel()
t.Run("from scratch", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=bare", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out)
})
t.Run("reserved go.mod name", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=go", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{go{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"go":{"containerEcho":{"stdout":"hello\n"}}}`, out)
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | t.Run("uses expected Go module name, camel-cases Dagger module name", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=My-Module", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{myModule{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"myModule":{"containerEcho":{"stdout":"hello\n"}}}`, out)
generated, err := modGen.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module main")
})
t.Run("creates go.mod beneath an existing go.mod if root points beneath it", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/go.mod", dagger.ContainerWithNewFileOpts{
Contents: "module example.com/test\n",
}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
Contents: "package foo\n",
}).
WithWorkdir("/work/ci"). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | With(daggerExec("init", "--name=beneathGoMod", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{beneathGoMod{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"beneathGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("names Go module after Dagger module", func(t *testing.T) {
generated, err := modGen.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, generated, "module main")
})
})
t.Run("respects existing go.mod", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
With(daggerExec("init", "--name=hasGoMod", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{hasGoMod{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("preserves module name", func(t *testing.T) {
generated, err := modGen.File("go.mod").Contents(ctx)
require.NoError(t, err) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | require.Contains(t, generated, "module example.com/test")
})
})
t.Run("respects parent go.mod if root points to it", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
generated := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
Contents: "package foo\n",
}).
With(daggerExec("init", "--name=child", "--sdk=go", "./child")).
WithWorkdir("/work/child").
With(daggerExec("develop")).
Directory("/work")
parentEntries, err := generated.Entries(ctx)
require.NoError(t, err)
require.Equal(t, []string{"child", "dagger.json", "foo.go", "go.mod", "go.sum"}, parentEntries)
childEntries, err := generated.Directory("child").Entries(ctx)
require.NoError(t, err)
require.NotContains(t, childEntries, "go.mod")
t.Run("preserves parent module name", func(t *testing.T) {
goMod, err := generated.File("go.mod").Contents(ctx)
require.NoError(t, err)
require.Contains(t, goMod, "module example.com/test")
})
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | t.Run("respects existing go.mod even if root points to parent that has go.mod", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
generated := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithExec([]string{"go", "mod", "init", "example.com/test"}).
WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{
Contents: "package foo\n",
}).
WithWorkdir("/work/child").
WithExec([]string{"go", "mod", "init", "my-mod"}).
WithWorkdir("/work").
With(daggerExec("init", "--name=child", "--sdk=go", "./child")).
WithWorkdir("/work/child").
With(daggerExec("develop")).
Directory("/work")
parentEntries, err := generated.Entries(ctx)
require.NoError(t, err)
require.Equal(t, []string{"child", "dagger.json", "foo.go", "go.mod"}, parentEntries)
childEntries, err := generated.Directory("child").Entries(ctx)
require.NoError(t, err)
require.Contains(t, childEntries, "go.mod")
require.Contains(t, childEntries, "go.sum")
})
t.Run("respects existing main.go", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `
package main
type HasMainGo struct {}
func (m *HasMainGo) Hello() string { return "Hello, world!" }
`,
}).
With(daggerExec("init", "--name=hasMainGo", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{hasMainGo{hello}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasMainGo":{"hello":"Hello, world!"}}`, out)
})
t.Run("respects existing main.go even if it uses types not generated yet", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{
Contents: `
package main
type HasDaggerTypes struct {}
func (m *HasDaggerTypes) Hello() *Container {
return dag.Container(). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | From("` + alpineImage + `").
WithExec([]string{"echo", "Hello, world!"})
}
`,
}).
With(daggerExec("init", "--name=hasDaggerTypes", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{hasDaggerTypes{hello{stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"hasDaggerTypes":{"hello":{"stdout":"Hello, world!\n"}}}`, out)
})
t.Run("respects existing package without creating main.go", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/notmain.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type HasNotMainGo struct {}
func (m *HasNotMainGo) Hello() string { return "Hello, world!" }
`,
}).
With(daggerExec("init", "--name=hasNotMainGo", "--sdk=go"))
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.
With(daggerQuery(`{hasNotMainGo{hello}}`)).
Stdout(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | require.NoError(t, err)
require.JSONEq(t, `{"hasNotMainGo":{"hello":"Hello, world!"}}`, out)
})
}
func TestModuleInitLICENSE(t *testing.T) {
t.Run("bootstraps Apache-2.0 LICENSE file if none found", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go"))
content, err := modGen.File("LICENSE").Contents(ctx)
require.NoError(t, err)
require.Contains(t, content, "Apache License, Version 2.0")
})
t.Run("creates LICENSE file in the directory specified by arg", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go", "./mymod"))
content, err := modGen.File("mymod/LICENSE").Contents(ctx)
require.NoError(t, err)
require.Contains(t, content, "Apache License, Version 2.0")
})
t.Run("does not bootstrap LICENSE file if it exists in the parent dir", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/LICENSE", dagger.ContainerWithNewFileOpts{
Contents: "doesnt matter",
}).
WithWorkdir("/work/sub").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go"))
_, err := modGen.File("LICENSE").Contents(ctx)
require.Error(t, err)
})
t.Run("bootstraps a LICENSE file when requested, even if it exists in the parent dir", func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
WithNewFile("/work/LICENSE", dagger.ContainerWithNewFileOpts{
Contents: "doesnt matter",
}).
WithWorkdir("/work/sub").
With(daggerExec("init", "--name=licensed-to-ill", "--sdk=go", "--license=MIT"))
content, err := modGen.File("LICENSE").Contents(ctx)
require.NoError(t, err)
require.Contains(t, content, "MIT License")
})
}
func TestModuleGit(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | sdk string
gitGeneratedFiles []string
gitIgnoredFiles []string
}
for _, tc := range []testCase{
{
sdk: "go",
gitGeneratedFiles: []string{
"/dagger.gen.go",
"/querybuilder/**",
},
},
{
sdk: "python",
gitGeneratedFiles: []string{
"/sdk/**",
},
gitIgnoredFiles: []string{
"/sdk",
},
},
{ |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | sdk: "typescript",
gitGeneratedFiles: []string{
"/sdk/**",
},
gitIgnoredFiles: []string{
"/sdk",
},
},
} {
tc := tc
t.Run(fmt.Sprintf("module %s git", tc.sdk), func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := goGitBase(t, c).
With(daggerExec("init", "--name=bare", "--sdk="+tc.sdk))
if tc.sdk == "go" {
logGen(ctx, t, modGen.Directory("."))
}
out, err := modGen.
With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out)
t.Run("configures .gitattributes", func(t *testing.T) {
ignore, err := modGen.File(".gitattributes").Contents(ctx)
require.NoError(t, err)
for _, fileName := range tc.gitGeneratedFiles {
require.Contains(t, ignore, fmt.Sprintf("%s linguist-generated\n", fileName))
}
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | if len(tc.gitIgnoredFiles) > 0 {
t.Run("configures .gitignore", func(t *testing.T) {
ignore, err := modGen.File(".gitignore").Contents(ctx)
require.NoError(t, err)
for _, fileName := range tc.gitIgnoredFiles {
require.Contains(t, ignore, fileName)
}
})
}
})
}
}
var goSignatures string
func TestModuleGoSignatures(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: goSignatures,
})
logGen(ctx, t, modGen.Directory("."))
t.Run("func Hello() string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"hello":"hello"}}`, out)
})
t.Run("func Echo(string) string", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | out, err := modGen.With(daggerQuery(`{minimal{echo(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echo":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoPointer(*string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoPointer":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoPointerPointer(**string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoPointerPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoPointerPointer":"hello...hello...hello..."}}`, out)
})
t.Run("func EchoOptional(string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptional(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptional":"hello...hello...hello..."}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptional}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptional":"default...default...default..."}}`, out)
})
t.Run("func EchoOptionalPointer(string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptionalPointer(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"hello...hello...hello..."}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptionalPointer}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"default...default...default..."}}`, out)
}) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | t.Run("func EchoOptionalSlice([]string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptionalSlice(msg: ["hello", "there"])}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"hello+there...hello+there...hello+there..."}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptionalSlice}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"foobar...foobar...foobar..."}}`, out)
})
t.Run("func Echoes([]string) []string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoes(msgs: ["hello"])}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoes":["hello...hello...hello..."]}}`, out)
})
t.Run("func EchoesVariadic(...string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoesVariadic(msgs: ["hello"])}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoesVariadic":"hello...hello...hello..."}}`, out)
})
t.Run("func HelloContext(context.Context) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloContext}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloContext":"hello context"}}`, out)
})
t.Run("func EchoContext(context.Context, string) string", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoContext(msg: "hello")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoContext":"ctx.hello...ctx.hello...ctx.hello..."}}`, out)
})
t.Run("func HelloStringError() (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloStringError}}`)).Stdout(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloStringError":"hello i worked"}}`, out)
})
t.Run("func HelloVoid()", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloVoid}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloVoid":null}}`, out)
})
t.Run("func HelloVoidError() error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{helloVoidError}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"helloVoidError":null}}`, out)
})
t.Run("func EchoOpts(string, string, int) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOpts":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOpts(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOpts":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInline(struct{string, string, int}) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInline(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInline":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlinePointer(*struct{string, string, int}) error", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlinePointer(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlinePointer":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlinePointer(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlinePointer":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlineCtx(ctx, struct{string, string, int}) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlineCtx(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineCtx":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlineCtx(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineCtx":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsInlineTags(struct{string, string, int}) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsInlineTags(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineTags":"hi"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{echoOptsInlineTags(msg: "hi", suffix: "!", times: 2)}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsInlineTags":"hi!hi!"}}`, out)
})
t.Run("func EchoOptsPragmas(string, string, int) error", func(t *testing.T) {
out, err := modGen.With(daggerQuery(`{minimal{echoOptsPragmas(msg: "hi")}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"echoOptsPragmas":"hi...hi...hi..."}}`, out)
})
}
func TestModuleGoSignaturesBuiltinTypes(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
type Minimal struct {}
func (m *Minimal) Read(ctx context.Context, dir Directory) (string, error) {
return dir.File("foo").Contents(ctx)
}
func (m *Minimal) ReadPointer(ctx context.Context, dir *Directory) (string, error) {
return dir.File("foo").Contents(ctx)
}
func (m *Minimal) ReadSlice(ctx context.Context, dir []Directory) (string, error) {
return dir[0].File("foo").Contents(ctx)
}
func (m *Minimal) ReadVariadic(ctx context.Context, dir ...Directory) (string, error) {
return dir[0].File("foo").Contents(ctx)
}
func (m *Minimal) ReadOptional(ctx context.Context, dir Optional[Directory]) (string, error) {
d, ok := dir.Get()
if ok {
return d.File("foo").Contents(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | }
return "", nil
}
`,
})
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.With(daggerQuery(`{directory{withNewFile(path: "foo", contents: "bar"){id}}}`)).Stdout(ctx)
require.NoError(t, err)
dirID := gjson.Get(out, "directory.withNewFile.id").String()
t.Run("func Read(ctx, Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{read(dir: "%s")}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"read":"bar"}}`, out)
})
t.Run("func ReadPointer(ctx, *Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readPointer(dir: "%s")}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readPointer":"bar"}}`, out)
})
t.Run("func ReadSlice(ctx, []Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readSlice(dir: ["%s"])}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readSlice":"bar"}}`, out)
})
t.Run("func ReadVariadic(ctx, ...Directory) (string, error)", func(t *testing.T) {
out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readVariadic(dir: ["%s"])}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readVariadic":"bar"}}`, out)
})
t.Run("func ReadOptional(ctx, Optional[Directory]) (string, error)", func(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | out, err := modGen.With(daggerQuery(fmt.Sprintf(`{minimal{readOptional(dir: "%s")}}`, dirID))).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readOptional":"bar"}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{readOptional}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"readOptional":""}}`, out)
})
}
func TestModuleGoSignaturesUnexported(t *testing.T) {
t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
type Foo struct {}
type bar struct {}
func (m *Minimal) Hello(name string) string {
return name
}
func (f *Foo) Hello(name string) string {
return name
}
func (b *bar) Hello(name string) string {
return name
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | `,
})
logGen(ctx, t, modGen.Directory("."))
objs := inspectModuleObjects(ctx, t, modGen)
require.Equal(t, 1, len(objs.Array()))
require.Equal(t, "Minimal", objs.Get("0.name").String())
modGen = c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
type Foo struct {}
type bar struct {}
func (m *Minimal) Hello(name string) Foo {
return Foo{}
}
func (f *Foo) Hello(name string) string {
return name
}
func (b *bar) Hello(name string) string {
return name
}
`,
})
logGen(ctx, t, modGen.Directory("."))
objs = inspectModuleObjects(ctx, t, modGen)
require.Equal(t, 2, len(objs.Array()))
require.Equal(t, "Minimal", objs.Get("0.name").String()) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | require.Equal(t, "MinimalFoo", objs.Get("1.name").String())
modGen = c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
type Foo struct {
Bar bar
}
type bar struct {}
func (m *Minimal) Hello(name string) Foo {
return Foo{}
}
func (f *Foo) Hello(name string) string {
return name
}
func (b *bar) Hello(name string) string {
return name
}
`,
})
logGen(ctx, t, modGen.Directory("."))
_, err := modGen.With(moduleIntrospection).Stderr(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
require.Contains(t, logs.String(), "cannot code-generate unexported type bar")
}
func TestModuleGoSignaturesMixMatch(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
func (m *Minimal) Hello(name string, opts struct{}, opts2 struct{}) string {
return name
}
`,
})
logGen(ctx, t, modGen.Directory("."))
_, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
require.Contains(t, logs.String(), "nested structs are not supported")
}
func TestModuleGoSignaturesNameConflict(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {
Foo Foo
Bar Bar
Baz Baz
}
type Foo struct {}
type Bar struct {}
type Baz struct {}
func (m *Foo) Hello(name string) string {
return name
}
func (f *Bar) Hello(name string, name2 string) string {
return name + name2
}
func (b *Baz) Hello() (string, error) {
return "", nil
}
`,
})
logGen(ctx, t, modGen.Directory(".")) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | objs := inspectModuleObjects(ctx, t, modGen)
require.Equal(t, 4, len(objs.Array()))
require.Equal(t, "Minimal", objs.Get("0.name").String())
require.Equal(t, "MinimalFoo", objs.Get("1.name").String())
require.Equal(t, "MinimalBar", objs.Get("2.name").String())
require.Equal(t, "MinimalBaz", objs.Get("3.name").String())
}
func TestModuleGoDocs(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: goSignatures,
})
logGen(ctx, t, modGen.Directory("."))
obj := inspectModuleObjects(ctx, t, modGen).Get("0")
require.Equal(t, "Minimal", obj.Get("name").String())
hello := obj.Get(`functions.#(name="hello")`)
require.Equal(t, "hello", hello.Get("name").String())
require.Empty(t, hello.Get("description").String())
require.Empty(t, hello.Get("args").Array())
echoOpts := obj.Get(`functions.#(name="echoOpts")`)
require.Equal(t, "echoOpts", echoOpts.Get("name").String())
require.Equal(t, "EchoOpts does some opts things", echoOpts.Get("description").String())
require.Len(t, echoOpts.Get("args").Array(), 3)
require.Equal(t, "msg", echoOpts.Get("args.0.name").String()) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | require.Equal(t, "the message to echo", echoOpts.Get("args.0.description").String())
require.Equal(t, "suffix", echoOpts.Get("args.1.name").String())
require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String())
require.Equal(t, "times", echoOpts.Get("args.2.name").String())
require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String())
echoOpts = obj.Get(`functions.#(name="echoOptsInline")`)
require.Equal(t, "echoOptsInline", echoOpts.Get("name").String())
require.Equal(t, "EchoOptsInline does some opts things", echoOpts.Get("description").String())
require.Len(t, echoOpts.Get("args").Array(), 3)
require.Equal(t, "msg", echoOpts.Get("args.0.name").String())
require.Equal(t, "the message to echo", echoOpts.Get("args.0.description").String())
require.Equal(t, "suffix", echoOpts.Get("args.1.name").String())
require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String())
require.Equal(t, "times", echoOpts.Get("args.2.name").String())
require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String())
echoOpts = obj.Get(`functions.#(name="echoOptsPragmas")`)
require.Equal(t, "echoOptsPragmas", echoOpts.Get("name").String())
require.Len(t, echoOpts.Get("args").Array(), 3)
require.Equal(t, "msg", echoOpts.Get("args.0.name").String())
require.Equal(t, "", echoOpts.Get("args.0.defaultValue").String())
require.Equal(t, "suffix", echoOpts.Get("args.1.name").String())
require.Equal(t, "String to append to the echoed message", echoOpts.Get("args.1.description").String())
require.Equal(t, "\"...\"", echoOpts.Get("args.1.defaultValue").String())
require.Equal(t, "times", echoOpts.Get("args.2.name").String())
require.Equal(t, "3", echoOpts.Get("args.2.defaultValue").String())
require.Equal(t, "Number of times to repeat the message", echoOpts.Get("args.2.description").String())
}
func TestModuleGoDocsEdgeCases(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
// Minimal is a thing
type Minimal struct {
// X is this
X, Y string // Y is not this
// +private |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | Z string
}
// some docs
func (m *Minimal) Hello(foo string, bar string,
// hello
baz string, qux string, x string, // lol
) string {
return foo + bar
}
func (m *Minimal) HelloMore(
// foo here
foo,
// bar here
bar string,
) string {
return foo + bar
}
func (m *Minimal) HelloMoreInline(opts struct{
// foo here
foo, bar string
}) string {
return opts.foo + opts.bar
}
func (m *Minimal) HelloAgain( // docs for helloagain
foo string,
bar string, // docs for bar
baz string,
) string {
return foo + bar
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | func (m *Minimal) HelloFinal(
foo string) string { // woops
return foo
}
`,
})
logGen(ctx, t, modGen.Directory("."))
obj := inspectModuleObjects(ctx, t, modGen).Get("0")
require.Equal(t, "Minimal", obj.Get("name").String())
require.Equal(t, "Minimal is a thing", obj.Get("description").String())
hello := obj.Get(`functions.#(name="hello")`)
require.Equal(t, "hello", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 5)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "", hello.Get("args.1.description").String())
require.Equal(t, "baz", hello.Get("args.2.name").String())
require.Equal(t, "hello", hello.Get("args.2.description").String())
require.Equal(t, "qux", hello.Get("args.3.name").String())
require.Equal(t, "", hello.Get("args.3.description").String())
require.Equal(t, "x", hello.Get("args.4.name").String())
require.Equal(t, "lol", hello.Get("args.4.description").String())
hello = obj.Get(`functions.#(name="helloMore")`)
require.Equal(t, "helloMore", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 2)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "foo here", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "bar here", hello.Get("args.1.description").String()) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | hello = obj.Get(`functions.#(name="helloMoreInline")`)
require.Equal(t, "helloMoreInline", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 2)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "foo here", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "", hello.Get("args.1.description").String())
hello = obj.Get(`functions.#(name="helloAgain")`)
require.Equal(t, "helloAgain", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 3)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "", hello.Get("args.0.description").String())
require.Equal(t, "bar", hello.Get("args.1.name").String())
require.Equal(t, "docs for bar", hello.Get("args.1.description").String())
require.Equal(t, "baz", hello.Get("args.2.name").String())
require.Equal(t, "", hello.Get("args.2.description").String())
hello = obj.Get(`functions.#(name="helloFinal")`)
require.Equal(t, "helloFinal", hello.Get("name").String())
require.Len(t, hello.Get("args").Array(), 1)
require.Equal(t, "foo", hello.Get("args.0.name").String())
require.Equal(t, "", hello.Get("args.0.description").String())
require.Len(t, obj.Get(`fields`).Array(), 2)
prop := obj.Get(`fields.#(name="x")`)
require.Equal(t, "x", prop.Get("name").String())
require.Equal(t, "X is this", prop.Get("description").String())
prop = obj.Get(`fields.#(name="y")`)
require.Equal(t, "y", prop.Get("name").String())
require.Equal(t, "", prop.Get("description").String())
}
func TestModuleGoWeirdFields(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Z string
type Minimal struct {
// field with single (normal) name
W string
// field with multiple names
X, Y string
// field with no names
Z
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | func New() Minimal {
return Minimal{
W: "-",
X: "-",
Y: "-",
Z: Z("-"),
}
}
// struct with no fields
type Bar struct{}
func (m *Minimal) Say(
// field with single (normal) name
a string,
// field with multiple names
b, c string,
// field with no names (not included, mixed names not allowed)
// string
) string {
return a + " " + b + " " + c
}
func (m *Minimal) Hello(
// field with no names
string,
) string {
return "hello"
}
func (m *Minimal) SayOpts(opts struct{
// field with single (normal) name
A string
// field with multiple names |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | B, C string
// field with no names (not included because of above)
// string
}) string {
return opts.A + " " + opts.B + " " + opts.C
}
func (m *Minimal) HelloOpts(opts struct{
// field with no names
string
}) string {
return "hello"
}
`,
})
logGen(ctx, t, modGen.Directory("."))
out, err := modGen.With(daggerQuery(`{minimal{w, x, y, z}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal": {"w": "-", "x": "-", "y": "-", "z": "-"}}`, out)
for _, name := range []string{"say", "sayOpts"} {
out, err := modGen.With(daggerQuery(`{minimal{%s(a: "hello", b: "world", c: "!")}}`, name)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, fmt.Sprintf(`{"minimal": {"%s": "hello world !"}}`, name), out)
}
for _, name := range []string{"hello", "helloOpts"} {
out, err := modGen.With(daggerQuery(`{minimal{%s(string: "")}}`, name)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, fmt.Sprintf(`{"minimal": {"%s": "hello"}}`, name), out)
}
}
func TestModuleGoOptionalMustBeNil(t *testing.T) { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
type Minimal struct {}
func (m *Minimal) Foo(x *Optional[*string]) string {
if v, _ := x.Get(); v != nil {
panic("uh oh")
}
return ""
}
func (m *Minimal) Bar(opts struct {
x *Optional[*string]
}) string {
if v, _ := opts.x.Get(); v != nil {
panic("uh oh")
}
return ""
}
func (m *Minimal) Baz(
// +optional |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | x *string,
) string {
if x != nil {
panic("uh oh")
}
return ""
}
func (m *Minimal) Qux(opts struct {
// +optional
x *string
}) string {
if opts.x != nil {
panic("uh oh")
}
return ""
}
`,
})
logGen(ctx, t, modGen.Directory("."))
for _, name := range []string{"foo", "bar", "baz", "qux"} {
out, err := modGen.With(daggerQuery(`{minimal{%s}}`, name)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, fmt.Sprintf(`{"minimal": {"%s": ""}}`, name), out)
}
}
func TestModuleGoFieldMustBeNil(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "fmt"
type Minimal struct {
Src *Directory
Name *string
}
func New() *Minimal {
return &Minimal{}
}
func (m *Minimal) IsEmpty() bool {
if m.Name != nil {
panic(fmt.Sprintf("name should be nil but is %v", m.Name))
}
if m.Src != nil {
panic(fmt.Sprintf("src should be nil but is %v", m.Src))
}
return true
}
`,
})
out, err := modGen.With(daggerQuery(`{minimal{isEmpty}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal": {"isEmpty": true}}`, out)
}
func TestModuleDescription(t *testing.T) {
t.Parallel()
for _, tc := range []struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | sdk string
source string
}{
{
sdk: "python",
source: `"""Test module, short description
Long description, with full sentences.
"""
from dagger import field, function, object_type
@object_type
class Test:
"""Test object, short description"""
foo: str = field(default="foo")
`,
},
{
sdk: "typescript",
source: `
/**
* Test module, short description
*
* Long description, with full sentences.
*/
import { object, field } from '@dagger.io/dagger' |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | /**
* Test object, short description
*/
@object()
class Test {
@field()
foo: string = "foo"
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
mod := inspectModule(ctx, t, modInit(ctx, t, c, tc.sdk, tc.source))
require.Equal(t,
"Test module, short description\n\nLong description, with full sentences.",
mod.Get("description").String(),
)
require.Equal(t,
"Test object, short description",
mod.Get("objects.0.asObject.description").String(),
)
})
}
}
func TestModulePrivateField(t *testing.T) {
t.Parallel()
for _, tc := range []struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | sdk string
source string
}{
{
sdk: "go",
source: `package main
type Minimal struct {
Foo string
Bar string // +private
}
func (m *Minimal) Set(foo string, bar string) *Minimal {
m.Foo = foo
m.Bar = bar
return m
}
func (m *Minimal) Hello() string {
return m.Foo + m.Bar
}
`,
},
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type
class Minimal:
foo: str = field(default="")
bar: str = ""
@function |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | def set(self, foo: str, bar: str) -> "Minimal":
self.foo = foo
self.bar = bar
return self
@function
def hello(self) -> str:
return self.foo + self.bar
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class Minimal {
@field()
foo: string
bar?: string
constructor(foo?: string, bar?: string) {
this.foo = foo
this.bar = bar
}
@func()
set(foo: string, bar: string): Minimal {
this.foo = foo
this.bar = bar
return this
}
@func()
hello(): string { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | return this.foo + this.bar
}
}
`,
},
} {
tc := tc
t.Run(tc.sdk, func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
modGen := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=minimal", "--sdk="+tc.sdk)).
With(sdkSource(tc.sdk, tc.source))
if tc.sdk == "go" {
logGen(ctx, t, modGen.Directory("."))
}
obj := inspectModuleObjects(ctx, t, modGen).Get("0")
require.Equal(t, "Minimal", obj.Get("name").String())
require.Len(t, obj.Get(`fields`).Array(), 1)
prop := obj.Get(`fields.#(name="foo")`)
require.Equal(t, "foo", prop.Get("name").String())
out, err := modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){hello}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"set":{"hello": "abcxyz"}}}`, out)
out, err = modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){foo}}}`)).Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"minimal":{"set":{"foo": "abc"}}}`, out)
_, err = modGen.With(daggerQuery(`{minimal{set(foo: "abc", bar: "xyz"){bar}}}`)).Stdout(ctx) |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | require.ErrorContains(t, err, `Minimal has no such field: "bar"`)
})
}
}
func TestModuleGoExtendCore(t *testing.T) {
t.Parallel()
var logs safeBuffer
c, ctx := connect(t, dagger.WithLogOutput(&logs))
_, err := c.Container().From(golangImage).
WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
WithWorkdir("/work").
With(daggerExec("init", "--name=container", "--sdk=go")).
WithNewFile("main.go", dagger.ContainerWithNewFileOpts{
Contents: `package main
import "context"
func (c *Container) Echo(ctx context.Context, msg string) (string, error) {
return c.WithExec([]string{"echo", msg}).Stdout(ctx)
}
`,
}).
With(daggerQuery(`{container{from(address:"` + alpineImage + `"){echo(msg:"echo!"){stdout}}}}`)).
Sync(ctx)
require.Error(t, err)
require.NoError(t, c.Close())
t.Log(logs.String())
require.Contains(t, logs.String(), "cannot define methods on objects from outside this module")
}
func TestModuleCustomTypes(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
import "strings"
type Test struct{}
func (m *Test) Repeater(msg string, times int) *Repeater {
return &Repeater{
Message: msg,
Times: times,
}
}
type Repeater struct {
Message string
Times int
}
func (t *Repeater) Render() string {
return strings.Repeat(t.Message, t.Times)
}
`, |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | },
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type
class Repeater:
message: str = field(default="")
times: int = field(default=0)
@function
def render(self) -> str:
return self.message * self.times
@function
def repeater(msg: str, times: int) -> Repeater:
return Repeater(message=msg, times=times)
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class Repeater {
@field()
message: string
@field()
times: number
constructor(message: string, times: number) {
this.message = message
this.times = times
} |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | @func()
render(): string {
return this.message.repeat(this.times)
}
}
@object()
class Test {
@func()
repeater(msg: string, times: number): Repeater {
return new Repeater(msg, times)
}
}
`,
},
} {
tc := tc
t.Run(fmt.Sprintf("custom %s types", tc.sdk), func(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
out, err := modInit(ctx, t, c, tc.sdk, tc.source).
With(daggerQuery(`{test{repeater(msg:"echo!", times: 3){render}}}`)).
Stdout(ctx)
require.NoError(t, err)
require.JSONEq(t, `{"test":{"repeater":{"render":"echo!echo!echo!"}}}`, out)
})
}
}
func TestModuleReturnTypeDetection(t *testing.T) {
t.Parallel()
type testCase struct { |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | sdk string
source string
}
for _, tc := range []testCase{
{
sdk: "go",
source: `package main
type Foo struct {}
type X struct {
Message string ` + "`json:\"message\"`" + ` |
closed | dagger/dagger | https://github.com/dagger/dagger | 6,532 | 🐞 Confusing error message when `Context` is not the first parameter of a function | ### What is the issue?
Mostly what the title says. The error message I get from putting the `Context` in the wrong place is cryptic.
### Dagger version
dagger v0.9.7
### Steps to reproduce
Create any Zenith module function and put the `context.Context` in any location but the first parameter.
### Log output
```
Error: failed to automate vcs: failed to get vcs ignored paths: input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
input: resolve: module: withSource: failed to get modified source directory for go module sdk codegen: process "/usr/local/bin/codegen --module . --propagate-logs=true --introspection-json-path /schema.json" did not complete successfully: exit code: 1
```
This was also in the output
```
Stderr:
internal error during module code generation: runtime error: invalid memory address or nil pointer dereference
``` | https://github.com/dagger/dagger/issues/6532 | https://github.com/dagger/dagger/pull/6551 | 5b273004464711d1efcf427da9cefa7dc389497d | dcee33ec84858610450ef30ddfcad60a9b9be053 | 2024-01-30T19:02:52Z | go | 2024-02-07T17:20:29Z | core/integration/module_test.go | }
func (m *Foo) MyFunction() X {
return X{Message: "foo"}
}
`,
},
{
sdk: "python",
source: `from dagger import field, function, object_type
@object_type
class X:
message: str = field(default="")
@function
def my_function() -> X:
return X(message="foo")
`,
},
{
sdk: "typescript",
source: `
import { object, func, field } from "@dagger.io/dagger"
@object()
class X {
@field()
message: string
constructor(message: string) {
this.message = message;
}
}
@object() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.