{"record":{"id":"3281dd8fdd967408","repo":"hashicorp/terraform","slug":"missing-state-name-3281dd","errorCode":null,"errorMessage":"missing state name","messagePattern":"missing state name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/oss/backend_state.go","lineNumber":31,"sourceCode":"\n\t\"github.com/aliyun/aliyun-oss-go-sdk/oss\"\n\t\"github.com/aliyun/aliyun-tablestore-go-sdk/tablestore\"\n\n\t\"github.com/hashicorp/terraform/internal/backend\"\n\t\"github.com/hashicorp/terraform/internal/states\"\n\t\"github.com/hashicorp/terraform/internal/states/remote\"\n\t\"github.com/hashicorp/terraform/internal/states/statemgr\"\n\t\"github.com/hashicorp/terraform/internal/tfdiags\"\n)\n\nconst (\n\tlockFileSuffix = \".tflock\"\n)\n\n// get a remote client configured for this state\nfunc (b *Backend) remoteClient(name string) (*RemoteClient, error) {\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"missing state name\")\n\t}\n\n\tclient := &RemoteClient{\n\t\tossClient:            b.ossClient,\n\t\tbucketName:           b.bucketName,\n\t\tstateFile:            b.stateFile(name),\n\t\tlockFile:             b.lockFile(name),\n\t\tserverSideEncryption: b.serverSideEncryption,\n\t\tacl:                  b.acl,\n\t\totsTable:             b.otsTable,\n\t\totsClient:            b.otsClient,\n\t}\n\tif b.otsEndpoint != \"\" && b.otsTable != \"\" {\n\t\t_, err := b.otsClient.DescribeTable(&tablestore.DescribeTableRequest{\n\t\t\tTableName: b.otsTable,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn client, fmt.Errorf(\"error describing table store %s: %#v\", b.otsTable, err)","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote-state/oss/backend_state.go#L13-L49","documentation":"Returned by (*Backend).remoteClient (internal/backend/remote-state/oss/backend_state.go:31) when the workspace name passed in is empty. remoteClient derives the OSS state file path (stateFile) and lock file path from the workspace, and an empty name would yield a malformed object key. The guard fails fast before any Alibaba Cloud OSS/OTS API call.","triggerScenarios":"Calling StateMgr(\"\") or DeleteWorkspace(\"\", _) on the oss backend; CLI/wrapper logic forwarding an unset workspace variable; automation reading the workspace from an unset TF_WORKSPACE.","commonSituations":"CI scripts with a missing/empty workspace env var; migration tooling that doesn't resolve the current workspace before invoking the backend; bugs in workspace resolution upstream of the OSS backend.","solutions":["Resolve the workspace name to a non-empty value before calling StateMgr/DeleteWorkspace.","Default to backend.DefaultStateName when no workspace is explicitly selected.","Validate at the call site and return a descriptive error to the caller."],"exampleFix":"// before\nclient, err := b.remoteClient(ws) // ws == \"\"\n\n// after\nif ws == \"\" {\n    ws = backend.DefaultStateName\n}\nclient, err := b.remoteClient(ws)","handlingStrategy":"validation","validationCode":"if name == \"\" {\n    name = backend.DefaultStateName\n}\nclient, err := b.remoteClient(name)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve the workspace to a non-empty value (default to \"default\") before invoking the OSS backend.","Validate workspace env vars are set in CI before running terraform.","Centralize workspace resolution so all backends receive a valid name."],"tags":["backend","oss","alibaba","workspace","validation"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}