{"record":{"id":"0fc72eb580064850","repo":"pulumi/pulumi","slug":"expected-a-v-got-a-s","errorCode":null,"errorMessage":"expected a %v, got a %s","messagePattern":"expected a (.+?), got a (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/go/pulumi/provider.go","lineNumber":433,"sourceCode":"\t\t\treturn err\n\t\t}\n\t\tdest.Set(result)\n\t\treturn nil\n\t}\n\n\tif dest.Type().Implements(inputType) {\n\t\t// Try to determine the input type from the interface.\n\t\tif it := internal.InputInterfaceTypeToConcreteType(dest.Type()); it != nil {\n\t\t\tinputType := it\n\t\t\tfor inputType.Kind() == reflect.Pointer {\n\t\t\t\tinputType = inputType.Elem()\n\t\t\t}\n\n\t\t\t//nolint:exhaustive // We only need to process a few types here.\n\t\t\tswitch inputType.Kind() {\n\t\t\tcase reflect.Bool:\n\t\t\t\tif !v.IsBool() {\n\t\t\t\t\treturn fmt.Errorf(\"expected a %v, got a %s\", inputType, v.TypeString())\n\t\t\t\t}\n\t\t\t\tresult := reflect.New(inputType).Elem()\n\t\t\t\tresult.SetBool(v.BoolValue())\n\t\t\t\tdest.Set(result)\n\t\t\t\treturn nil\n\t\t\tcase reflect.Int:\n\t\t\t\tif !v.IsNumber() {\n\t\t\t\t\treturn fmt.Errorf(\"expected an %v, got a %s\", inputType, v.TypeString())\n\t\t\t\t}\n\t\t\t\tresult := reflect.New(inputType).Elem()\n\t\t\t\tresult.SetInt(int64(v.NumberValue()))\n\t\t\t\tdest.Set(result)\n\t\t\t\treturn nil\n\t\t\tcase reflect.Float64:\n\t\t\t\tif !v.IsNumber() {\n\t\t\t\t\treturn fmt.Errorf(\"expected an %v, got a %s\", inputType, v.TypeString())\n\t\t\t\t}\n\t\t\t\tresult := reflect.New(inputType).Elem()","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/go/pulumi/provider.go#L415-L451","documentation":"While copying a known property value into a destination whose Input interface resolves to a bool-based concrete type, the property value is not a boolean. The guard `v.IsBool()` fails before `SetBool` is called, protecting against reflect panics.","triggerScenarios":"copyInputTo receives a PropertyValue that is a string, number, object, etc., while the destination type's Input concrete type has reflect.Kind Bool (e.g. pulumi.BoolInput / pulumi.BoolPtrInput fields), typically inside copyToStruct unmarshaling of an InvokeResult or typed asset value.","commonSituations":"A provider returns a boolean property as a string (\"true\") or as a number (0/1); schema drift between the provider's serialized output and the generated Go SDK types; hand-written structs whose ElementType maps to bool while the data is textual.","solutions":["Fix the provider or resource so the property is serialized as an actual boolean","Change the destination struct field to pulumi.StringInput (or the actual emitted type) and convert explicitly","Coerce the value at the source (e.g. strconv.ParseBool) before it is wrapped into a PropertyValue","Verify provider/SDK schema versions are in sync; regenerate the typed SDK"],"exampleFix":"// before\nEnabled pulumi.BoolInput `pulumi:\"enabled\"` // provider returns \"true\" as string\n// after\nEnabled pulumi.StringInput `pulumi:\"enabled\"`\n// then: pulumi.Bool(strings.EqualFold(enabled, \"true\"))","handlingStrategy":"validation","validationCode":"if b, ok := rawValue.(bool); !ok {\n    return fmt.Errorf(\"property %q must be a bool, got %T\", name, rawValue)\n}","typeGuard":"func isBoolProperty(v resource.PropertyValue) bool { return v.IsBool() }","tryCatchPattern":"if err := copyInputTo(ctx, v, dest); err != nil {\n    var te *TypeError\n    if errors.As(err, &te) { /* normalize bool-like strings with strconv.ParseBool */ }\n    return err\n}","preventionTips":["Ensure providers serialize booleans as JSON bools, not \"true\"/0","Quote-check config sources (JSON/YAML) so bools are not quoted","Keep provider and generated SDK schemas in sync","Add schema-level type tests for boolean properties"],"tags":["go","reflection","unmarshal","type-mismatch"],"backgroundTag":"unmarshal-type-mismatch","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}