temporalio/temporal · error

field NamespaceId is empty

Error message

field NamespaceId is empty

What it means

errEmptyNamespaceID is a sentinel in common/archiver/util.go returned by ValidateHistoryArchiveRequest, ValidateGetRequest, ValidateVisibilityArchivalRequest, and ValidateQueryRequest when the request's NamespaceId field is the empty string. NamespaceId (the internal UUID-style ID, not the name) is mandatory to locate and authorize the archive.

Source

Thrown at common/archiver/util.go:12

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),

View on GitHub (pinned to bde624efd1)

Solutions

  1. Populate NamespaceID with the namespace's internal ID (resolve via namespace cache/registry if you only have the name) before calling the validate/archive API.
  2. Verify the code path that builds the request actually copies NamespaceID from the original request or namespace object.
  3. Call the Validate* function early in your flow to fail fast with this clear error instead of deeper in persistence.

Example fix

// before
req := &archiver.GetHistoryRequest{WorkflowID: wid, RunID: rid, PageSize: 100}
err := archiver.ValidateGetRequest(req)
// after
req := &archiver.GetHistoryRequest{NamespaceID: nsID, WorkflowID: wid, RunID: rid, PageSize: 100}
err := archiver.ValidateGetRequest(req)
Defensive patterns

Strategy: validation

Validate before calling

func validateNamespaceID(nsID string) error {
    if nsID == "" {
        return errors.New("NamespaceId must be set before archival request")
    }
    return nil
}

Try / catch

if err := archiver.ValidateGetRequest(req); err != nil {
    if errors.Is(err, archiver.ErrEmptyNamespaceID) {
        return nil, status.Error(codes.InvalidArgument, "NamespaceId is required")
    }
    return nil, err
}

Prevention

When it happens

Trigger: Calling any of the four Validate* functions with a request struct/proto whose NamespaceID (or GetNamespaceId()) is unset — e.g. a hand-built ArchiveHistoryRequest, GetHistoryRequest, archiverspb.VisibilityRecord, or QueryVisibilityRequest without NamespaceId populated.

Common situations: Custom archival code constructing requests manually; namespace deletion/resolution failures upstream leaving the ID blank; proto fields simply not set when copying from a different request type.

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/85f1b50e031a7b0c. Report an issue: GitHub.