{"record":{"id":"272ff3c488041220","repo":"hashicorp/terraform","slug":"expected-s-to-be-in-the-range-d-d-got-d","errorCode":null,"errorMessage":"expected %s to be in the range (%d - %d), got %d","messagePattern":"expected (.+?) to be in the range \\((.+?) - (.+?)\\), got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/oss/backend.go","lineNumber":79,"sourceCode":"\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{\n\t\t\t\"access_key\": {\n\t\t\t\tType:        schema.TypeString,\n\t\t\t\tOptional:    true,\n\t\t\t\tDescription: \"Alibaba Cloud Access Key ID\",","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/oss/backend.go#L61-L97","documentation":"Thrown by the ValidateFunc for 'session_expiration' in the OSS backend when the integer value falls outside the allowed range of 900 to 3600 seconds (15 minutes to 1 hour). This mirrors Alibaba Cloud STS constraints on assumed-role session durations.","triggerScenarios":"ValidateFunc checks value < 900 or value > 3600. The user configures session_expiration in the OSS backend block to a value outside [900, 3600]. Common invalid values: 0, 60, 600 (if expecting minutes), 7200, or negative numbers.","commonSituations":"Developer confuses seconds with minutes (sets 60 expecting 1 hour). Developer sets a very long expiration (7200) not supported by Alibaba Cloud STS. Developer leaves a placeholder value of 0. Copy-paste from AWS STS configuration where different limits apply (AWS allows 900-43200).","solutions":["Set session_expiration to a value between 900 and 3600 (inclusive), e.g. 3600 for the maximum 1-hour session.","If you expected minutes, multiply by 60 — 30 minutes = 1800 seconds.","Omit the field entirely if the default STS duration is acceptable."],"exampleFix":"// before (out of range)\nsession_expiration = 7200\n// after (within 900-3600 range)\nsession_expiration = 3600","handlingStrategy":"validation","validationCode":"// Validate session_expiration range before Terraform init\nfunc validateSessionExpiration(seconds int) error {\n    const min, max = 900, 3600\n    if seconds < min || seconds > max {\n        return fmt.Errorf(\"session_expiration must be between %d and %d seconds (got %d); note: values are in seconds, not minutes\", min, max, seconds)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember Alibaba Cloud STS session durations are in seconds, 900-3600 (15min to 1hr).","Omit session_expiration if you don't need to customize it — the default STS duration is usually fine.","Do not copy AWS STS values (which allow up to 43200 seconds) without adjusting for Alibaba Cloud's lower maximum."],"tags":["oss","validation","session-expiration","sts"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}