{"record":{"id":"f864f4517e8f96c4","repo":"hashicorp/terraform","slug":"expected-type-of-s-to-be-int","errorCode":null,"errorMessage":"expected type of %s to be int","messagePattern":"expected type of (.+?) to be int","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/oss/backend.go","lineNumber":75,"sourceCode":"\t\t\t\t\tOptional:    true,\n\t\t\t\t\tDescription: \"The session name to use when assuming the role.\",\n\t\t\t\t\tDefaultFunc: schema.MultiEnvDefaultFunc([]string{\"ALICLOUD_ASSUME_ROLE_SESSION_NAME\", \"ALIBABA_CLOUD_ROLE_SESSION_NAME\"}, \"\"),\n\t\t\t\t},\n\t\t\t\t\"policy\": {\n\t\t\t\t\tType:        schema.TypeString,\n\t\t\t\t\tOptional:    true,\n\t\t\t\t\tDescription: \"The permissions applied when assuming a role. You cannot use this policy to grant permissions which exceed those of the role that is being assumed.\",\n\t\t\t\t},\n\t\t\t\t\"session_expiration\": {\n\t\t\t\t\tType:        schema.TypeInt,\n\t\t\t\t\tOptional:    true,\n\t\t\t\t\tDescription: \"The time after which the established session for assuming role expires.\",\n\t\t\t\t\tValidateFunc: func(v interface{}, k string) ([]string, []error) {\n\t\t\t\t\t\tmin := 900\n\t\t\t\t\t\tmax := 3600\n\t\t\t\t\t\tvalue, ok := v.(int)\n\t\t\t\t\t\tif !ok {\n\t\t\t\t\t\t\treturn nil, []error{fmt.Errorf(\"expected type of %s to be int\", k)}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif value < min || value > max {\n\t\t\t\t\t\t\treturn nil, []error{fmt.Errorf(\"expected %s to be in the range (%d - %d), got %d\", k, min, max, v)}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nil, nil\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n}\n\n// New creates a new backend for OSS remote state.\nfunc New() backend.Backend {\n\ts := &schema.Backend{\n\t\tSchema: map[string]*schema.Schema{","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/oss/backend.go#L57-L93","documentation":"Thrown by the ValidateFunc for the 'session_expiration' field in the OSS backend schema when the value cannot be type-asserted to int. Since the field is declared as schema.TypeInt, the Terraform SDK should always deliver an int, making this a defensive guard against unexpected internal type mismatches.","triggerScenarios":"The ValidateFunc receives v interface{} where v.(int) fails. With schema.TypeInt declared, this path is essentially unreachable through normal Terraform configuration parsing — it would require a bug in the Terraform core SDK or a programmatic schema injection with a wrong type.","commonSituations":"Effectively unreachable through normal HCL configuration. Could theoretically surface if a third-party tool or wrapper programmatically constructs the backend schema with incorrect types, or if there's a version mismatch between the OSS backend and the Terraform SDK.","solutions":["Ensure you are using a compatible version of Terraform/OpenTofu that aligns with this backend's SDK version.","If the value is coming from a variable, ensure the variable type is declared as number/integer, not string.","Report a bug if this triggers with a well-formed HCL configuration — it indicates an SDK-level type issue."],"exampleFix":"// Ensure session_expiration is set as an integer in HCL:\nterraform {\n  backend \"oss\" {\n    // before (string — should never parse this way with TypeInt)\n    session_expiration = \"3600\"\n    // after\n    session_expiration = 3600\n  }\n}","handlingStrategy":"type-guard","validationCode":"// This is a ValidateFunc guard — pre-validation happens at Terraform's schema level.\n// Ensure the HCL value is an integer:\n// session_expiration = 3600  (correct)\n// session_expiration = \"3600\" (may trigger type issues depending on SDK version)","typeGuard":"// Type guard for programmatic access to schema validation\nfunc isIntSessionExpiration(v interface{}) bool {\n    _, ok := v.(int)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Always use bare integers (not quoted strings) for integer-type backend attributes in HCL.","Keep Terraform/OpenTofu version compatible with the backend plugin version.","If using variables, declare them with type = number."],"tags":["oss","validation","type-check","session-expiration"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}