{"record":{"id":"0f8c59ffa23bab38","repo":"hoppscotch/hoppscotch","slug":"failed-to-parse-authentication-parameters-from-www","errorCode":null,"errorMessage":"Failed to parse authentication parameters from WWW-Authenticate header","messagePattern":"Failed to parse authentication parameters from WWW-Authenticate header","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/hoppscotch-cli/src/utils/auth/digest.ts","lineNumber":142,"sourceCode":"\n      if (authHeader) {\n        const authParams = parseDigestAuthHeader(authHeader);\n        if (\n          authParams &&\n          authParams.realm &&\n          authParams.nonce &&\n          authParams.qop\n        ) {\n          return {\n            realm: authParams.realm,\n            nonce: authParams.nonce,\n            qop: authParams.qop,\n            opaque: authParams.opaque,\n            algorithm: authParams.algorithm,\n          };\n        }\n      }\n      throw new Error(\n        \"Failed to parse authentication parameters from WWW-Authenticate header\"\n      );\n    }\n\n    throw new Error(`Unexpected response: ${initialResponse.status}`);\n  } catch (error) {\n    const errMsg = error instanceof Error ? error.message : error;\n\n    console.error(\n      exceptionColors.FAIL(\n        `\\n Error fetching initial digest auth info: ${errMsg} \\n`\n      )\n    );\n    throw error; // Re-throw the error to handle it further up the chain if needed\n  }\n};\n","sourceCodeStart":124,"sourceCodeEnd":159,"githubUrl":"https://github.com/hoppscotch/hoppscotch/blob/1acb8a3a7581e4db32ba0d529170c4669a2e1053/packages/hoppscotch-cli/src/utils/auth/digest.ts#L124-L159","documentation":"Thrown by the CLI fetchInitialDigestAuthInfo when the server returned 401 but the WWW-Authenticate header was missing, absent, or could not be parsed into realm/nonce/qop. parseDigestAuthHeader regex /([a-z0-9]+)=\"([^\"]+)\"/gi requires quoted key=value pairs; if any of realm, nonce, or qop is missing the function refuses to proceed.","triggerScenarios":"CLI Digest auth call against a server whose 401 response lacks a parseable WWW-Authenticate header — e.g. a server returning Basic auth challenge, a malformed header, a non-Digest challenge, or no header at all.","commonSituations":"Wrong auth scheme selected (server expects Basic, not Digest); proxy strips WWW-Authenticate; server uses a non-standard digest format without quoted values; endpoint returns 401 from a generic handler that didn't set the header.","solutions":["Confirm the server actually speaks Digest auth (check the raw 401 response headers).","Switch to the auth scheme the server advertises (Basic, Bearer, API key).","If the header is present but non-standard, the parser regex may need extending to unquoted values.","Capture the raw response to verify WWW-Authenticate exists and contains realm/nonce/qop."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-check: probe the endpoint once to confirm it advertises Digest.\nconst probe = await axios.request({ url, method, validateStatus: () => true });\nconst wwwAuth = Object.keys(probe.headers).find(h => h.toLowerCase() === 'www-authenticate');\nif (!wwwAuth || !/digest/i.test(probe.headers[wwwAuth] as string)) {\n  throw new Error('Endpoint does not advertise Digest auth');\n}","typeGuard":"function hasDigestParams(p: Record<string,string>|null): p is { realm:string; nonce:string; qop:string } {\n  return !!p && !!p.realm && !!p.nonce && !!p.qop;\n}","tryCatchPattern":"try {\n  await fetchInitialDigestAuthInfo(url, method, false);\n} catch (e) {\n  if (e instanceof Error && /WWW-Authenticate/.test(e.message)) {\n    // prompt user to switch auth scheme or fix server header\n  } else throw e;\n}","preventionTips":["Verify the server's auth scheme with a curl -I before wiring Digest in the CLI.","Make parseDigestAuthHeader tolerant of unquoted values per RFC 7235 where appropriate.","Log the raw WWW-Authenticate header on parse failure to speed diagnosis."],"tags":["cli","auth","digest-auth","http","parsing"],"backgroundTag":null,"analyzedSha":"1acb8a3a7581e4db32ba0d529170c4669a2e1053","analyzedAt":"2026-08-12T11:34:52.648Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}