dagger/dagger · error
cannot create Boolean from %T
Error message
cannot create Boolean from %T
What it means
Boolean.DecodeInput only accepts Go bool and parseable bool strings; the default branch rejects all other types, reporting the offending type with %T. This enforces strict typing for the GraphQL Boolean scalar.
Source
Thrown at dagql/types.go:514
Kind: ast.Scalar,
Name: b.TypeName(),
Description: "The `Boolean` scalar type represents `true` or `false`.",
BuiltIn: true,
}
}
func (Boolean) DecodeInput(val any) (Input, error) {
switch x := val.(type) {
case bool:
return NewBoolean(x), nil
case string: // from default
b, err := strconv.ParseBool(x)
if err != nil {
return nil, err
}
return NewBoolean(b), nil
default:
return nil, fmt.Errorf("cannot create Boolean from %T", x)
}
}
var _ Input = Boolean(false)
func (Boolean) Decoder() InputDecoder {
return Boolean(false)
}
func (b Boolean) ToLiteral() call.Literal {
return call.NewLiteralBool(b.Bool())
}
func (b Boolean) Bool() bool {
return bool(b)
}
func (b Boolean) MarshalJSON() ([]byte, error) {View on GitHub (pinned to 82ba2681db)
Solutions
- Pass an actual Go bool (or the strings "true"/"false" which ParseBool accepts)
- Convert numeric flags explicitly: v != 0 before passing
- Fix the GraphQL variable type to Boolean in the operation
Example fix
// before flag := 1 // from config dag.Boolean(flag) // cannot create Boolean from int // after dag.Boolean(flag != 0)
Defensive patterns
Strategy: type-guard
Validate before calling
func isBoolDecodable(v any) bool {
switch x := v.(type) {
case bool:
return true
case string:
_, err := strconv.ParseBool(x)
return err == nil
}
return false
} Type guard
func isBoolDecodable(v any) bool {
switch x := v.(type) {
case bool:
return true
case string:
_, err := strconv.ParseBool(x)
return err == nil
}
return false
} Try / catch
v, err := decode(val)
if err != nil {
return fmt.Errorf("bad Boolean input: %w", err)
} Prevention
- Pass real Go bools for Boolean arguments
- Avoid encoding booleans as 0/1 ints in configs feeding GraphQL variables
- Validate string flags parse with strconv.ParseBool first
When it happens
Trigger: Passing nil, numbers (0/1), json.Number, or complex types as a Boolean input — e.g. a GraphQL variable typed Boolean but supplied a number or null.
Common situations: Config values stored as 0/1 ints forwarded to a Boolean argument; JSON where booleans were encoded as 0/1 numbers; SDK wrappers passing any-typed flags.
Related errors
- expected instance of %T, got %T
- cannot create Int from %T
- cannot create Float from %T
- cannot create String from %T
- merge module types into schema: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/280b5682074ead81.
Report an issue: GitHub.