{"record":{"id":"9ccbd82c4b645b43","repo":"HangfireIO/Hangfire","slug":"unable-to-parse-queue-path-queuepath","errorCode":null,"errorMessage":"Unable to parse queue path '{queuePath}'","messagePattern":"Unable to parse queue path '(.+?)'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.SqlServer.Msmq/MessageQueueExtensions.cs","lineNumber":108,"sourceCode":"        {\n            var match = GetQueuePathMatch(messageQueue.Path);\n\n            var computerName = match.Groups[\"computerName\"].Value;\n            var queueType = match.Groups[\"queueType\"].Value;\n            var queue = match.Groups[\"queue\"].Value;\n\n            if (computerName == \".\")\n                computerName = null;\n\n            return GetQueueCount(computerName, queueType, queue);\n        }\n\n        internal static Match GetQueuePathMatch(string queuePath)\n        {\n            var matches = regex.Matches(queuePath);\n            if (matches.Count != 1)\n            {\n                throw new InvalidOperationException($\"Unable to parse queue path '{queuePath}'\");\n            }\n\n            return matches[0];\n        }\n\n        private static long GetQueueCount(string computerName, string queueType, string queue)\n        {\n            if (string.IsNullOrEmpty(computerName)) computerName = null;\n            string queuePath = $\"queue=Direct=OS:{computerName ?? \".\"}\";\n\n            if (!String.IsNullOrEmpty(queueType))\n            {\n                queuePath += $\"\\\\{queueType}\";\n            }\n\n            queuePath += $\"\\\\{queue}\";\n\n            return GetCount(computerName, queuePath);","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.SqlServer.Msmq/MessageQueueExtensions.cs#L90-L126","documentation":"InvalidOperationException thrown by MessageQueueExtensions.GetQueuePathMatch when a regex applied to an MSMQ queue path does not produce exactly one match. Hangfire.SqlServer.Msmq expects a well-formed MSMQ queue path (e.g. FormatName:DIRECT=OS:machine\\private$\\queue or machine\\queue) to parse into computer/queue parts; zero or multiple matches mean the string is not a recognizable MSMQ path.","triggerScenarios":"Configuring SqlServerStorage with MSMQ dequeuing (UseMsmqQueues) and passing a queue path string that does not match the expected MSMQ path grammar; counting queues on a malformed path.","commonSituations":"Typing the queue path with wrong separators; using a label or description instead of a FormatName/path; missing the private$ segment; copy-paste introducing extra characters; environment-specific path differences.","solutions":["Correct the path to the standard MSMQ format, e.g. @\".\\private$\\hangfire\" or \"FormatName:DIRECT=OS:machine\\\\private$\\queue\".","Verify the queue exists in the MSMQ snap-in / Computer Management before referencing it.","Normalize all configured queue paths through a single helper that validates the regex up front."],"exampleFix":"// before\nGlobalConfiguration.Configuration.UseSqlServerStorage(cs).UseMsmqQueues(@\"bad:path\\\\MyQueue\");\n\n// after\nGlobalConfiguration.Configuration.UseSqlServerStorage(cs).UseMsmqQueues(@\".\\private$\\hangfire\");","handlingStrategy":"validation","validationCode":"static readonly Regex MsmqPath =\n    new(@\"^(?:FormatName:Direct=OS:)?(?<computer>[^\\\\]+)\\\\(?:private\\\\$\\\\)?(?<queue>[^\\\\]+)$\",\n        RegexOptions.Compiled | RegexOptions.IgnoreCase);\n\nstatic string AssertValidMsmqPath(string path)\n{\n    if (!MsmqPath.IsMatch(path))\n        throw new ArgumentException($\"Invalid MSMQ queue path: '{path}'.\");\n    return path;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the MSMQ path string before passing it to UseMsmqQueues.","Confirm the queue exists in Computer Management > Message Queuing before configuring Hangfire.","Keep MSMQ path format consistent across environments via a config value."],"tags":["msmq","configuration","parsing"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}