temporalio/temporal · error

field Namespace is empty

Error message

field Namespace is empty

What it means

errEmptyNamespace is a sentinel in common/archiver/util.go returned by ValidateHistoryArchiveRequest and ValidateVisibilityArchivalRequest when the request's Namespace (the namespace *name*, distinct from NamespaceId) is empty. Both the ID and the human-readable name are recorded in archived data, so the name is required.

Solutions

  1. Set the Namespace field to the namespace name alongside NamespaceID before validation.
  2. Resolve the name from the namespace registry/cache if only the ID is available at the call site.
  3. Add an upstream check that both NamespaceID and Namespace are non-empty when constructing archival requests.

Example fix

// before
rec := &archiverspb.VisibilityRecord{NamespaceId: nsID, WorkflowId: wid, RunId: rid}
err := archiver.ValidateVisibilityArchivalRequest(rec)
// after
rec := &archiverspb.VisibilityRecord{NamespaceId: nsID, Namespace: nsName, WorkflowId: wid, RunId: rid}
err := archiver.ValidateVisibilityArchivalRequest(rec)
Defensive patterns

Strategy: validation

Validate before calling

func validateNamespacePair(nsID, ns string) error {
    if nsID == "" || ns == "" {
        return errors.New("both NamespaceId and Namespace must be set")
    }
    return nil
}

Try / catch

if err := archiver.ValidateVisibilityArchivalRequest(rec); err != nil {
    if errors.Is(err, archiver.ErrEmptyNamespace) {
        return nil, status.Error(codes.InvalidArgument, "Namespace (name) is required")
    }
    return nil, err
}

Prevention

When it happens

Trigger: Calling ValidateHistoryArchiveRequest with ArchiveHistoryRequest.Namespace == "" or ValidateVisibilityArchivalRequest with VisibilityRecord.GetNamespace() == ""; typical when a caller sets NamespaceID but forgets Namespace.

Common situations: Custom archiver implementations building VisibilityRecord protos by hand; migration code that populates only the new ID-style field; namespace name lookup returning empty after namespace was deleted or renamed.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01). Data as JSON: /api/errors/c0bb67b74e06cfa7. Report an issue: GitHub.

Appendix: source

Thrown at common/archiver/util.go:13

package archiver

import (
	"errors"

	archiverspb "go.temporal.io/server/api/archiver/v1"
	"go.temporal.io/server/common/log"
	"go.temporal.io/server/common/log/tag"
)

var (
	errEmptyNamespaceID      = errors.New("field NamespaceId is empty")
	errEmptyNamespace        = errors.New("field Namespace is empty")
	errEmptyWorkflowID       = errors.New("field WorkflowId is empty")
	errEmptyRunID            = errors.New("field RunId is empty")
	errInvalidPageSize       = errors.New("field PageSize should be greater than 0")
	errEmptyWorkflowTypeName = errors.New("field WorkflowTypeName is empty")
	errEmptyStartTime        = errors.New("field StartTime is empty")
	errEmptyCloseTime        = errors.New("field CloseTime is empty")
)

// TagLoggerWithArchiveHistoryRequestAndURI tags logger with fields in the archive history request and the URI
func TagLoggerWithArchiveHistoryRequestAndURI(logger log.Logger, request *ArchiveHistoryRequest, URI string) log.Logger {
	return log.With(
		logger,
		tag.ShardID(request.ShardID),
		tag.ArchivalRequestNamespaceID(request.NamespaceID),
		tag.ArchivalRequestNamespace(request.Namespace),
		tag.ArchivalRequestWorkflowID(request.WorkflowID),
		tag.ArchivalRequestRunID(request.RunID),
		tag.ArchivalRequestBranchToken(request.BranchToken),

View on GitHub (pinned to bde624efd1)