{"record":{"id":"85f1b50e031a7b0c","repo":"temporalio/temporal","slug":"field-namespaceid-is-empty","errorCode":null,"errorMessage":"field NamespaceId is empty","messagePattern":"field NamespaceId is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/archiver/util.go","lineNumber":12,"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),","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/archiver/util.go#L1-L30","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Verify the code path that builds the request actually copies NamespaceID from the original request or namespace object.","Call the Validate* function early in your flow to fail fast with this clear error instead of deeper in persistence."],"exampleFix":"// before\nreq := &archiver.GetHistoryRequest{WorkflowID: wid, RunID: rid, PageSize: 100}\nerr := archiver.ValidateGetRequest(req)\n// after\nreq := &archiver.GetHistoryRequest{NamespaceID: nsID, WorkflowID: wid, RunID: rid, PageSize: 100}\nerr := archiver.ValidateGetRequest(req)","handlingStrategy":"validation","validationCode":"func validateNamespaceID(nsID string) error {\n    if nsID == \"\" {\n        return errors.New(\"NamespaceId must be set before archival request\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := archiver.ValidateGetRequest(req); err != nil {\n    if errors.Is(err, archiver.ErrEmptyNamespaceID) {\n        return nil, status.Error(codes.InvalidArgument, \"NamespaceId is required\")\n    }\n    return nil, err\n}","preventionTips":["Always resolve and set NamespaceId (internal ID) when constructing archival requests.","Run Validate* functions immediately after building requests to fail fast.","Check namespace resolution code paths for silent empty results."],"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"}