{"record":{"id":"426f1318514c4d02","repo":"NousResearch/hermes-agent","slug":"noun-is-too-short-to-be-valid","errorCode":null,"errorMessage":"${Noun} is too short to be valid.","messagePattern":"(.+?) is too short to be valid\\.","errorType":"exception","errorClass":"LoadoutError","httpStatus":null,"severity":"warning","filePath":"apps/desktop/src/lib/loadout.ts","lineNumber":254,"sourceCode":"    // Strip ALL whitespace, not just the ends — a pasted code often picks up soft\n    // wraps / newlines, and base64 decoding chokes on any of it.\n    const cleaned = code.replace(/\\s+/g, '')\n    const raw = cleaned.startsWith(spec.prefix) ? cleaned.slice(spec.prefix.length) : cleaned\n\n    if (!raw) {\n      throw new Err(`That doesn't look like a ${noun}.`)\n    }\n\n    let framed: Uint8Array\n\n    try {\n      framed = fromBase64Url(raw)\n    } catch {\n      throw new Err(`That doesn't look like a ${noun}.`)\n    }\n\n    if (framed.length <= HEAD_BYTES) {\n      throw new Err(`${Noun} is too short to be valid.`)\n    }\n\n    const head = new BitReader(framed.subarray(0, HEAD_BYTES))\n    const version = head.uint(8)\n    const storedSum = head.uint(16)\n\n    if (version !== spec.version) {\n      throw new Err(`${Noun} is version ${version}; this build reads version ${spec.version}.`)\n    }\n\n    const payload = framed.subarray(HEAD_BYTES)\n\n    if (checksum16(payload) !== storedSum) {\n      throw new Err(`${Noun} looks corrupted (checksum mismatch).`)\n    }\n\n    try {\n      return spec.read(new BitReader(inflateSync(payload)))","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/apps/desktop/src/lib/loadout.ts#L236-L272","documentation":"Thrown by the loadout codec's decode() in apps/desktop/src/lib/loadout.ts:254 when the decoded framed bytes are not longer than HEAD_BYTES — the fixed header holding the 8-bit version and 16-bit checksum. A payload that decodes from base64url but is byte-empty or header-sized-or-smaller cannot possibly carry a framed body, so it is rejected before any bit-reading. Distinguishes 'too short' from 'not base64 at all' to give an accurate paste-error message.","triggerScenarios":"A base64url string that decodes to 0–N bytes where N <= HEAD_BYTES (e.g. 'AA' or 'AAA'); a code where the payload was stripped after emission; an encode() bug that framed only the header with an empty body.","commonSituations":"Truncated pastes that happen to keep valid base64 shape; placeholder/obfuscated codes; test vectors built from header-only buffers; a producer bug emitting prefix+header without a deflated payload.","solutions":["Re-copy the complete code — truncation that preserves base64 validity is the usual cause.","If producing codes programmatically, verify encode() output decodes to more than HEAD_BYTES bytes in a round-trip test.","Check the pasted code against the original length; loadout codes carry real payloads so they are never this short.","Surface the typed Err message in the paste UI."],"exampleFix":"// before\nconst result = decode(userCode) // header-only code throws here\n\n// after — cheap length sanity before decode\nconst payloadLen = Math.floor((userCode.replace(/\\s+/g, '').length) * 3 / 4)\nif (payloadLen <= 4) { showPasteError('Code is incomplete — copy the whole thing'); return }\nconst result = decode(userCode)","handlingStrategy":"validation","validationCode":"function plausibleCodeLength(raw: string, headBytes: number): boolean {\n  // base64url chars x 3/4 approximates decoded bytes; require strictly more than the header\n  return raw.length * 3 / 4 > headBytes\n}","typeGuard":null,"tryCatchPattern":"try { const v = decode(input) } catch (e) { if (e instanceof Err && /too short/.test(e.message)) { showPasteError('Code looks incomplete — copy the entire code'); return null } throw e }","preventionTips":["Validate decoded-length plausibility before decode","Round-trip test producers to guarantee header-plus-body output","Treat 'too short' as truncation — recopy the full code","Don't ship placeholder codes in UI copy or tests"],"tags":["desktop","loadout","validation","share-codes","truncation"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}