{"record":{"id":"527e756103889ce9","repo":"stablyai/orca","slug":"invalid-argument-527e75","errorCode":"invalid_argument","errorMessage":"Clipboard text is too large to copy safely.","messagePattern":"Clipboard text is too large to copy safely\\.","errorType":"validation","errorClass":"RuntimeClientError","httpStatus":null,"severity":"error","filePath":"src/main/computer/computer-clipboard-paste-validation.ts","lineNumber":15,"sourceCode":"import {\n  CLIPBOARD_TEXT_MEASURE_YIELD_CODE_UNITS,\n  CLIPBOARD_TEXT_WRITE_TOO_LARGE_ERROR,\n  assertClipboardTextWriteWithinLimit,\n  assertClipboardTextWriteWithinLimitWithYield,\n  isClipboardTextWriteTooLargeError\n} from '../../shared/clipboard-text'\nimport { RuntimeClientError } from './runtime-client-error'\n\nexport function validateComputerClipboardPasteText(text: string): void {\n  try {\n    assertClipboardTextWriteWithinLimit(text)\n  } catch (error) {\n    if (isClipboardTextWriteTooLargeError(error)) {\n      throw new RuntimeClientError('invalid_argument', CLIPBOARD_TEXT_WRITE_TOO_LARGE_ERROR)\n    }\n    throw error\n  }\n}\n\nexport async function validateComputerClipboardPasteTextWithYield(text: string): Promise<void> {\n  try {\n    // Why: accepted paste-sized payloads must not monopolize the main process\n    // while preserving the provider-facing invalid_argument error contract.\n    await assertClipboardTextWriteWithinLimitWithYield(text)\n  } catch (error) {\n    if (isClipboardTextWriteTooLargeError(error)) {\n      throw new RuntimeClientError('invalid_argument', CLIPBOARD_TEXT_WRITE_TOO_LARGE_ERROR)\n    }\n    throw error\n  }\n}\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/computer/computer-clipboard-paste-validation.ts#L1-L33","documentation":"Thrown by validateComputerClipboardPasteText (the synchronous path) when the paste text exceeds the clipboard write byte limit (CLIPBOARD_TEXT_WRITE_MAX_BYTES = 16 MiB UTF-8). It is surfaced as a RuntimeClientError with code 'invalid_argument' and the shared CLIPBOARD_TEXT_WRITE_TOO_LARGE_ERROR message, so it maps cleanly to a provider-facing invalid-argument rejection.","triggerScenarios":"validateComputerClipboardPasteText(text) where measureClipboardTextByteLength exceeds CLIPBOARD_TEXT_WRITE_MAX_BYTES (16 MiB). Reached directly for small payloads or via validateComputerClipboardPasteTextWithBoundedYield when text.length <= CLIPBOARD_TEXT_MEASURE_YIELD_CODE_UNITS (256K code units).","commonSituations":"An agent action tries to paste a huge file body, a base64 blob, or an oversized log dump; an LLM-generated pasteText param exceeds the limit; a test fixture uses an oversized string.","solutions":["Truncate or chunk the text before calling paste so its UTF-8 size stays under 16 MiB.","Stream the large content to the target via a file or IPC channel instead of the clipboard.","Reject oversized payloads at the action-validation layer with a clear user-facing message before they reach the clipboard path."],"exampleFix":"// before: pasting a multi-MiB blob\nvalidateComputerClipboardPasteText(hugeBlob) // throws invalid_argument\n\n// after: bound the size before pasting\nimport { CLIPBOARD_TEXT_WRITE_MAX_BYTES, measureClipboardTextByteLength } from '../../shared/clipboard-text'\nconst safe = measureClipboardTextByteLength(hugeBlob).byteLength <= CLIPBOARD_TEXT_WRITE_MAX_BYTES\n  ? hugeBlob : hugeBlob.slice(0, CLIPBOARD_TEXT_WRITE_MAX_BYTES)\nvalidateComputerClipboardPasteText(safe)","handlingStrategy":"validation","validationCode":"import {\n  CLIPBOARD_TEXT_WRITE_MAX_BYTES,\n  measureClipboardTextByteLength\n} from '../../shared/clipboard-text'\n\nfunction isWithinClipboardWriteLimit(text: string): boolean {\n  return measureClipboardTextByteLength(text).byteLength <= CLIPBOARD_TEXT_WRITE_MAX_BYTES\n}\n\nif (!isWithinClipboardWriteLimit(text)) {\n  // truncate or chunk before pasting\n}","typeGuard":"import { RuntimeClientError } from './runtime-client-error'\n\nfunction isClipboardTooLargeError(error: unknown): boolean {\n  return (\n    error instanceof RuntimeClientError &&\n    error.code === 'invalid_argument' &&\n    error.message === 'Clipboard text is too large to copy safely.'\n  )\n}","tryCatchPattern":"try {\n  validateComputerClipboardPasteText(text)\n} catch (error) {\n  if (error instanceof RuntimeClientError && error.code === 'invalid_argument') {\n    // size guard: chunk the paste or reject with a user-facing message\n    text = text.slice(0, CLIPBOARD_TEXT_WRITE_MAX_BYTES)\n    validateComputerClipboardPasteText(text)\n  } else {\n    throw error\n  }\n}","preventionTips":["Measure UTF-8 byte length before large paste operations.","Prefer streaming large content via file/IPC over the clipboard.","Reject oversized payloads in the UI/agent layer with a clear message."],"tags":["computer-use","clipboard","validation","size-limit","invalid-argument"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}