{"record":{"id":"20ad1e488619d4a2","repo":"chatboxai/chatbox","slug":"a-license-key-is-required-to-claim-the-agent-mode","errorCode":null,"errorMessage":"A license key is required to claim the Agent Mode reward","messagePattern":"A license key is required to claim the Agent Mode reward","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/renderer/packages/remote.ts","lineNumber":1085,"sourceCode":"      method: 'GET',\n      headers: {\n        'Content-Type': 'application/json',\n        ...(await getChatboxHeaders()),\n      },\n    },\n    {\n      parseChatboxRemoteError: true,\n      retry: 2,\n    }\n  )\n  const json: Response = await res.json()\n  return json.data\n}\n\nexport async function claimFreeAgentModeReward(licenseKey: string): Promise<ClaimedAgentModeReward> {\n  const normalizedLicenseKey = licenseKey.trim()\n  if (!normalizedLicenseKey) {\n    throw new Error('A license key is required to claim the Agent Mode reward')\n  }\n\n  const afetch = await getAfetch()\n  const res = await afetch(\n    `${getAPIOrigin()}/api/license/claim-free-agent-mode-reward`,\n    {\n      method: 'POST',\n      headers: {\n        ...(await getChatboxHeaders()),\n        Authorization: `Bearer ${normalizedLicenseKey}`,\n      },\n    },\n    {\n      parseChatboxRemoteError: true,\n      retry: 0,\n    }\n  )\n  return ClaimFreeAgentModeRewardResponseSchema.parse(await res.json())","sourceCodeStart":1067,"sourceCodeEnd":1103,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/remote.ts#L1067-L1103","documentation":"Thrown by claimFreeAgentModeReward() when the supplied license key is empty after trimming. It is a pre-flight guard before the network call, so a blank/whitespace key never reaches the API. The check is `if (!normalizedLicenseKey) throw ...`.","triggerScenarios":"Calling claimFreeAgentModeReward(''), claimFreeAgentModeReward('   '), or with an undefined/null coerced to empty string. The trim() then emptiness check fires before getAfetch.","commonSituations":"UI button enabled with an empty license input; a variable bound to the input was never populated; copy-paste of whitespace-only text; programmatic call with a missing argument.","solutions":["Provide a non-empty license key string.","Disable the claim action in the UI until the trimmed input is non-empty.","If scripting, validate the argument is a non-blank string before calling."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function nonBlankKey(key: string): boolean {\n  return key.trim().length > 0\n}\nif (!nonBlankKey(licenseKey)) {\n  // disable claim button; do not call claimFreeAgentModeReward\n}","typeGuard":"function isNonBlankString(s: unknown): s is string {\n  return typeof s === 'string' && s.trim().length > 0\n}","tryCatchPattern":"try {\n  await claimFreeAgentModeReward(licenseKey)\n} catch (e) {\n  if (e instanceof Error && e.message === 'A license key is required to claim the Agent Mode reward') {\n    // focus the license input\n  }\n}","preventionTips":["Disable the claim action until input is non-empty.","Trim and validate license keys in the UI.","Never pass undefined/null from a bound variable without a default."],"tags":["license","validation","user-input","agent-mode"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}