{"record":{"id":"5a15accb16230621","repo":"hashicorp/terraform","slug":"must-not-be-null","errorCode":null,"errorMessage":"must not be null","messagePattern":"must not be null","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/backendbase/helper.go","lineNumber":106,"sourceCode":"// Unless the fallback value is null itself, this function guarantees to never\n// return null.\nfunc GetAttrEnvDefaultFallback(v cty.Value, attrName string, defEnv string, fallback cty.Value) cty.Value {\n\tret := GetAttrEnvDefault(v, attrName, defEnv)\n\tif ret.IsNull() {\n\t\treturn fallback\n\t}\n\treturn ret\n}\n\n// IntValue converts a cty value into a Go int64, or returns an error if that's\n// not possible.\nfunc IntValue(v cty.Value) (int64, error) {\n\tv, err := convert.Convert(v, cty.Number)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif v.IsNull() {\n\t\treturn 0, fmt.Errorf(\"must not be null\")\n\t}\n\tbf := v.AsBigFloat()\n\tret, acc := bf.Int64()\n\tif acc != big.Exact {\n\t\treturn 0, fmt.Errorf(\"must not be a whole number\")\n\t}\n\treturn ret, nil\n}\n\n// BoolValue converts a cty value Go bool, or returns an error if that's not\n// possible.\nfunc BoolValue(v cty.Value) (bool, error) {\n\tv, err := convert.Convert(v, cty.Bool)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif v.IsNull() {\n\t\treturn false, fmt.Errorf(\"must not be null\")","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/backendbase/helper.go#L88-L124","documentation":"Returned by backendbase.IntValue when, after converting the cty.Value to cty.Number, the value is null. IntValue is the helper used by backends (e.g. http backend's retry_max, retry_wait_min/max at backend/remote-state/http/backend.go:187/198/209) to read integer attributes from the backend configuration block.","triggerScenarios":"Returned at internal/backend/backendbase/helper.go:106 when v.IsNull() is true after convert.Convert(v, cty.Number). Triggered by any backend config schema using IntValue for a required integer attribute that the user left unset/null.","commonSituations":"Declaring a backend block but omitting a required integer field (e.g. `retry_max` for the http backend). Setting the attribute to null explicitly. A backend config that conditionally omits the field.","solutions":["Provide the integer attribute in the backend block, e.g. `retry_max = 2`.","If the attribute is optional, ensure the backend applies a default cty.Number before calling IntValue, or use GetAttrEnvDefaultFallback.","Fall back to an environment variable via GetAttrEnvDefault when the attribute is absent.","Validate the backend config schema early and report a clear 'attribute X is required' message."],"exampleFix":"// before\nterraform {\n  backend \"http\" {\n    address = \"https://state.example.com\"\n    # retry_max omitted -> null -> 'must not be null'\n  }\n}\n// after\nterraform {\n  backend \"http\" {\n    address   = \"https://state.example.com\"\n    retry_max = 2\n  }\n}","handlingStrategy":"validation","validationCode":"v := getAttrOrNull(config, \"retry_max\")\nif v.IsNull() {\n    return errors.New(\"retry_max must not be null\")\n}\nn, err := backendbase.IntValue(v)","typeGuard":"func isIntNullError(err error) bool {\n    return err != nil && err.Error() == \"must not be null\"\n}","tryCatchPattern":"n, err := backendbase.IntValue(v)\nif err != nil {\n    return fmt.Errorf(\"backend config: %w\", err)\n}","preventionTips":["Provide all required integer backend attributes.","Apply cty.Number defaults in the backend schema before IntValue.","Document required int fields clearly."],"tags":["backend","config","validation","http-backend"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}