{"record":{"id":"4043110638854bc8","repo":"dagger/dagger","slug":"implicit-input-q-resolved-to-nil","errorCode":null,"errorMessage":"implicit input %q resolved to nil","messagePattern":"implicit input %q resolved to nil","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dagql/objects.go","lineNumber":982,"sourceCode":"\t\tdef.Directives = append(def.Directives, experimental(spec.ExperimentalReason))\n\t}\n\treturn def\n}\n\nfunc (spec *FieldSpec) resolveImplicitInputCallArgs(ctx context.Context, inputArgs map[string]Input) ([]*ResultCallArg, error) {\n\tif spec == nil || len(spec.ImplicitInputs) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tinputIdxByName := make(map[string]int, len(spec.ImplicitInputs))\n\timplicitArgs := make([]*ResultCallArg, 0, len(spec.ImplicitInputs))\n\tfor _, implicitInput := range spec.ImplicitInputs {\n\t\tinputVal, err := implicitInput.Resolver(ctx, inputArgs)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"resolve implicit input %q: %w\", implicitInput.Name, err)\n\t\t}\n\t\tif inputVal == nil {\n\t\t\treturn nil, fmt.Errorf(\"implicit input %q resolved to nil\", implicitInput.Name)\n\t\t}\n\n\t\tnewInput, err := resultCallArgFromInput(ctx, implicitInput.Name, inputVal, false)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"resolve implicit input %q: %w\", implicitInput.Name, err)\n\t\t}\n\t\tif idx, ok := inputIdxByName[implicitInput.Name]; ok {\n\t\t\timplicitArgs[idx] = newInput\n\t\t\tcontinue\n\t\t}\n\t\tinputIdxByName[implicitInput.Name] = len(implicitArgs)\n\t\timplicitArgs = append(implicitArgs, newInput)\n\t}\n\tsort.Slice(implicitArgs, func(i, j int) bool {\n\t\treturn implicitArgs[i].Name < implicitArgs[j].Name\n\t})\n\treturn implicitArgs, nil\n}","sourceCodeStart":964,"sourceCodeEnd":1000,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/dagql/objects.go#L964-L1000","documentation":"An ImplicitInput resolver completed without error but returned a nil Input value. dagql requires implicit inputs to resolve to a concrete value because they are attached to every cached call; a nil would be meaningless as a cache key/argument, so the call is rejected (dagql/objects.go:982).","triggerScenarios":"A custom ImplicitInput whose Resolver returns `nil, nil` — e.g. an optional implicit value where the author forgot to return a typed default when the value is absent.","commonSituations":"Implicit inputs keyed on optional context data (current directory, client version) where lookup silently yields nothing; mis-typed nil return of a typed nil pointer vs untyped nil interface.","solutions":["Change the resolver to return a valid default Input when the underlying value is absent.","Explicitly return an error instead of (nil, nil) when the value genuinely cannot be resolved, so the message is actionable.","If using a typed pointer, ensure you convert it to a non-nil typed Input value before returning."],"exampleFix":"// before\nfunc resolve(ctx context.Context, args InputArgs) (Input, error) {\n    v := lookup(ctx)\n    return v, nil // nil when lookup fails\n}\n// after\nfunc resolve(ctx context.Context, args InputArgs) (Input, error) {\n    v := lookup(ctx)\n    if v == nil { return dagql.String(\"default\"), nil }\n    return v, nil\n}","handlingStrategy":"validation","validationCode":"val, err := resolver(ctx, args)\nif err != nil { return err }\nif val == nil { return fmt.Errorf(\"implicit input %q resolved to nil\", name) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never return (nil, nil) from an ImplicitInput Resolver; return a default or an error.","Prefer value types over typed-nil pointers for implicit inputs.","Add a table test asserting every registered ImplicitInput resolves non-nil in a default context."],"tags":["dagql","go","implicit-input","nil","resolver"],"backgroundTag":"nil-value-returned","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}