{"record":{"id":"c0bb67b74e06cfa7","repo":"temporalio/temporal","slug":"field-namespace-is-empty","errorCode":null,"errorMessage":"field Namespace is empty","messagePattern":"field Namespace is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/archiver/util.go","lineNumber":13,"sourceCode":"package archiver\n\nimport (\n\t\"errors\"\n\n\tarchiverspb \"go.temporal.io/server/api/archiver/v1\"\n\t\"go.temporal.io/server/common/log\"\n\t\"go.temporal.io/server/common/log/tag\"\n)\n\nvar (\n\terrEmptyNamespaceID      = errors.New(\"field NamespaceId is empty\")\n\terrEmptyNamespace        = errors.New(\"field Namespace is empty\")\n\terrEmptyWorkflowID       = errors.New(\"field WorkflowId is empty\")\n\terrEmptyRunID            = errors.New(\"field RunId is empty\")\n\terrInvalidPageSize       = errors.New(\"field PageSize should be greater than 0\")\n\terrEmptyWorkflowTypeName = errors.New(\"field WorkflowTypeName is empty\")\n\terrEmptyStartTime        = errors.New(\"field StartTime is empty\")\n\terrEmptyCloseTime        = errors.New(\"field CloseTime is empty\")\n)\n\n// TagLoggerWithArchiveHistoryRequestAndURI tags logger with fields in the archive history request and the URI\nfunc TagLoggerWithArchiveHistoryRequestAndURI(logger log.Logger, request *ArchiveHistoryRequest, URI string) log.Logger {\n\treturn log.With(\n\t\tlogger,\n\t\ttag.ShardID(request.ShardID),\n\t\ttag.ArchivalRequestNamespaceID(request.NamespaceID),\n\t\ttag.ArchivalRequestNamespace(request.Namespace),\n\t\ttag.ArchivalRequestWorkflowID(request.WorkflowID),\n\t\ttag.ArchivalRequestRunID(request.RunID),\n\t\ttag.ArchivalRequestBranchToken(request.BranchToken),","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/archiver/util.go#L1-L31","documentation":"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.","triggerScenarios":"Calling ValidateHistoryArchiveRequest with ArchiveHistoryRequest.Namespace == \"\" or ValidateVisibilityArchivalRequest with VisibilityRecord.GetNamespace() == \"\"; typical when a caller sets NamespaceID but forgets Namespace.","commonSituations":"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.","solutions":["Set the Namespace field to the namespace name alongside NamespaceID before validation.","Resolve the name from the namespace registry/cache if only the ID is available at the call site.","Add an upstream check that both NamespaceID and Namespace are non-empty when constructing archival requests."],"exampleFix":"// before\nrec := &archiverspb.VisibilityRecord{NamespaceId: nsID, WorkflowId: wid, RunId: rid}\nerr := archiver.ValidateVisibilityArchivalRequest(rec)\n// after\nrec := &archiverspb.VisibilityRecord{NamespaceId: nsID, Namespace: nsName, WorkflowId: wid, RunId: rid}\nerr := archiver.ValidateVisibilityArchivalRequest(rec)","handlingStrategy":"validation","validationCode":"func validateNamespacePair(nsID, ns string) error {\n    if nsID == \"\" || ns == \"\" {\n        return errors.New(\"both NamespaceId and Namespace must be set\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := archiver.ValidateVisibilityArchivalRequest(rec); err != nil {\n    if errors.Is(err, archiver.ErrEmptyNamespace) {\n        return nil, status.Error(codes.InvalidArgument, \"Namespace (name) is required\")\n    }\n    return nil, err\n}","preventionTips":["Set both NamespaceId and Namespace together; never copy only one.","Resolve namespace name from the registry/cache before archival calls.","Handle deleted/renamed namespaces by failing early with a clear error."],"tags":["go","archival","request-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}