hashicorp/terraform · error

missing state name

Error message

missing state name

What it means

Attribute.InternalValidate was called on a nil *Attribute pointer. The exported method guards the nil receiver and returns this error rather than panicking. Internally, a nil entry in a Block's Attributes map is caught earlier with a different message, so this specific message surfaces when callers invoke Attribute.InternalValidate directly on nil.

Solutions

  1. Skip nil attribute pointers before calling InternalValidate, or initialize them.
  2. When validating a whole Block, prefer Block.InternalValidate which already handles nil map entries.
  3. Add a nil check at the call site and surface a clearer upstream error.

Example fix

// before
var attr *configschema.Attribute
if err := attr.InternalValidate("name"); err != nil { return err }
// after
if attr == nil { return fmt.Errorf("name: attribute is nil") }
if err := attr.InternalValidate("name"); err != nil { return err }
Defensive patterns

Strategy: type-guard

Validate before calling

// Nil-check attribute pointers before calling InternalValidate.
for name, attr := range block.Attributes {
    if attr == nil {
        return fmt.Errorf("%s: attribute is nil", name)
    }
    if err := attr.InternalValidate(name); err != nil { return err }
}

Type guard

func attributeNotNil(a *configschema.Attribute) bool { return a != nil }

Prevention

When it happens

Trigger: Calling `var a *configschema.Attribute; a.InternalValidate("x")`, or passing a nil attribute pointer through code that calls its InternalValidate. Guard at internal_validate.go:132 is `if a == nil`.

Common situations: Provider test helper that iterates attributes without nil-checking; refactoring that leaves an attribute pointer uninitialized before validation.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/3281dd8fdd967408. Report an issue: GitHub.

Appendix: source

Thrown at internal/backend/remote-state/oss/backend_state.go:31

	"github.com/aliyun/aliyun-oss-go-sdk/oss"
	"github.com/aliyun/aliyun-tablestore-go-sdk/tablestore"

	"github.com/hashicorp/terraform/internal/backend"
	"github.com/hashicorp/terraform/internal/states"
	"github.com/hashicorp/terraform/internal/states/remote"
	"github.com/hashicorp/terraform/internal/states/statemgr"
	"github.com/hashicorp/terraform/internal/tfdiags"
)

const (
	lockFileSuffix = ".tflock"
)

// get a remote client configured for this state
func (b *Backend) remoteClient(name string) (*RemoteClient, error) {
	if name == "" {
		return nil, errors.New("missing state name")
	}

	client := &RemoteClient{
		ossClient:            b.ossClient,
		bucketName:           b.bucketName,
		stateFile:            b.stateFile(name),
		lockFile:             b.lockFile(name),
		serverSideEncryption: b.serverSideEncryption,
		acl:                  b.acl,
		otsTable:             b.otsTable,
		otsClient:            b.otsClient,
	}
	if b.otsEndpoint != "" && b.otsTable != "" {
		_, err := b.otsClient.DescribeTable(&tablestore.DescribeTableRequest{
			TableName: b.otsTable,
		})
		if err != nil {
			return client, fmt.Errorf("error describing table store %s: %#v", b.otsTable, err)

View on GitHub (pinned to d32a084675)