{"record":{"id":"280b5682074ead81","repo":"dagger/dagger","slug":"cannot-create-boolean-from-t","errorCode":null,"errorMessage":"cannot create Boolean from %T","messagePattern":"cannot create Boolean from %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dagql/types.go","lineNumber":514,"sourceCode":"\t\tKind:        ast.Scalar,\n\t\tName:        b.TypeName(),\n\t\tDescription: \"The `Boolean` scalar type represents `true` or `false`.\",\n\t\tBuiltIn:     true,\n\t}\n}\n\nfunc (Boolean) DecodeInput(val any) (Input, error) {\n\tswitch x := val.(type) {\n\tcase bool:\n\t\treturn NewBoolean(x), nil\n\tcase string: // from default\n\t\tb, err := strconv.ParseBool(x)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn NewBoolean(b), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"cannot create Boolean from %T\", x)\n\t}\n}\n\nvar _ Input = Boolean(false)\n\nfunc (Boolean) Decoder() InputDecoder {\n\treturn Boolean(false)\n}\n\nfunc (b Boolean) ToLiteral() call.Literal {\n\treturn call.NewLiteralBool(b.Bool())\n}\n\nfunc (b Boolean) Bool() bool {\n\treturn bool(b)\n}\n\nfunc (b Boolean) MarshalJSON() ([]byte, error) {","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/dagql/types.go#L496-L532","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nflag := 1 // from config\ndag.Boolean(flag) // cannot create Boolean from int\n// after\ndag.Boolean(flag != 0)","handlingStrategy":"type-guard","validationCode":"func isBoolDecodable(v any) bool {\n    switch x := v.(type) {\n    case bool:\n        return true\n    case string:\n        _, err := strconv.ParseBool(x)\n        return err == nil\n    }\n    return false\n}","typeGuard":"func isBoolDecodable(v any) bool {\n    switch x := v.(type) {\n    case bool:\n        return true\n    case string:\n        _, err := strconv.ParseBool(x)\n        return err == nil\n    }\n    return false\n}","tryCatchPattern":"v, err := decode(val)\nif err != nil {\n    return fmt.Errorf(\"bad Boolean input: %w\", err)\n}","preventionTips":["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"],"tags":["go","graphql","boolean-scalar","type-mismatch"],"backgroundTag":"scalar-type-mismatch","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"}