{"record":{"id":"892f51dda215c701","repo":"usebruno/bruno","slug":"cookie-name-is-required","errorCode":null,"errorMessage":"Cookie name is required","messagePattern":"Cookie name is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/cookies/index.ts","lineNumber":306,"sourceCode":"      maybeCallback?: (err?: Error | undefined) => void\n    ) {\n      // Determine the callback\n      let callback: ((err?: Error | undefined) => void) | undefined;\n      if (typeof maybeCallback === 'function') {\n        callback = maybeCallback;\n      } else if (typeof valueOrCallback === 'function') {\n        callback = valueOrCallback as (err?: Error | undefined) => void;\n      }\n\n      const executeSetCookie = () => {\n        if (!url) throw new Error('URL is required');\n\n        // CASE 1: name/value pair provided\n        if (typeof nameOrCookieObj === 'string') {\n          const cookieName = nameOrCookieObj;\n          const cookieValue = typeof valueOrCallback === 'string' ? valueOrCallback : '';\n\n          if (!cookieName) throw new Error('Cookie name is required');\n\n          const cookie = new Cookie(\n            hasHostPrefix(cookieName)\n              ? { key: cookieName, value: cookieValue }\n              : { key: cookieName, value: cookieValue, domain: new URL(url).hostname }\n          );\n\n          cookieJar.setCookieSync(cookie, url, { ignoreError: true });\n          return;\n        }\n\n        // CASE 2: cookie object provided\n        if (typeof nameOrCookieObj === 'object' && nameOrCookieObj !== null) {\n          const obj = { ...(nameOrCookieObj as any) } as any;\n\n          if (!obj.key && obj.name) obj.key = obj.name;\n          if (!obj.key) throw new Error('cookieObject.key (name) is required');\n","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/cookies/index.ts#L288-L324","documentation":"Thrown by setCookie when the name/value form is used (nameOrCookieObj is a string) but the string is empty. The branch constructs a Cookie keyed by this name, so an empty key is rejected before reaching the cookie jar.","triggerScenarios":"Calling setCookie(url, '', 'value') — the second argument is an empty string while the third (value) is also a string, selecting CASE 1.","commonSituations":"Cookie name sourced from a parsed header or variable that resolved to empty; the caller passed value as the second arg by mistake (arg-order confusion).","solutions":["Pass a non-empty cookie name as the second argument.","Double-check argument order: (url, name, value) — not (url, value, name).","Skip the setCookie call when the computed name is empty."],"exampleFix":"// before\ncookieJar.setCookie(url, '', 'value123');\n\n// after\ncookieJar.setCookie(url, 'session_id', 'value123');","handlingStrategy":"validation","validationCode":"if (!name || !name.trim()) throw new Error('Cookie name cannot be empty');\ncookieJar.setCookie(url, name, value);","typeGuard":"function isValidCookieName(n) { return typeof n === 'string' && n.trim().length > 0; }","tryCatchPattern":"try { cookieJar.setCookie(url, name, value); }\ncatch (e) { if (e.message === 'Cookie name is required') { /* pick a name */ } else throw e; }","preventionTips":["Document and assert argument order: (url, name, value).","Skip cookie writes whose name resolves to empty rather than calling setCookie anyway.","Keep a registry of known cookie names to avoid typos."],"tags":["cookies","validation","configuration"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}