{"record":{"id":"d9b7167a7ec33b0f","repo":"jackwener/OpenCLI","slug":"attachmentid-id-is-not-a-uuid","errorCode":null,"errorMessage":"attachmentId \"${id}\" is not a UUID","messagePattern":"attachmentId \"(.+?)\" is not a UUID","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/slock/attachment-download.js","lineNumber":42,"sourceCode":"\ncli({\n  site: SLOCK_SITE,\n  name: 'attachment-download',\n  access: 'read',\n  description: 'Download an attachment to a local file. Resolves a signed CDN URL in the page, then fetches bytes node-side (no CORS).',\n  domain: SLOCK_DOMAIN,\n  strategy: Strategy.COOKIE,\n  browser: true,\n  siteSession: 'persistent',\n  args: [\n    { name: 'attachmentId', positional: true, required: true, help: 'Attachment UUID' },\n    { name: 'out', help: 'Local path to write to. Defaults to ./<attachmentId>.bin' },\n    { name: 'server', help: 'Override active server slug' },\n  ],\n  columns: ['attachmentId', 'out', 'sizeBytes'],\n  func: async (page, kwargs) => {\n    const id = String(kwargs.attachmentId ?? '').trim();\n    if (!UUID_RE.test(id)) throw new ArgumentError(`attachmentId \"${id}\" is not a UUID`);\n    const out = path.resolve(String(kwargs.out ?? `./${id}.bin`));\n\n    // Step 1 — in-page, resolve the signed URL with the user's Slock session.\n    await page.goto(SLOCK_HOME_URL);\n    const snippet = buildFetchSnippet({\n      method: 'GET',\n      path: `/attachments/${encodeURIComponent(id)}/url`,\n      serverScoped: true,\n      serverIdOverride: kwargs.server,\n    });\n    const result = await page.evaluate(`(async () => { ${snippet} })()`);\n    const rows = dispatchEvaluateResult(result);\n    const data = Array.isArray(rows) ? rows[0] : rows;\n    const url = data?.url;\n    if (!url) throw new CommandExecutionError(`no signed url returned for attachment ${id}`);\n\n    // Step 2 — Node side, fetch the bytes from the signed CDN URL. No auth\n    // header (URL is pre-signed); no Origin (Node fetch has none) so CORS","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/slock/attachment-download.js#L24-L60","documentation":"An ArgumentError thrown during argument validation of the slock attachment-download CLI command: the provided attachmentId does not match UUID_RE, so it cannot be a valid Slock attachment identifier. The download flow (signed URL resolution, CDN fetch) is aborted before any network calls.","triggerScenarios":"Passing kwargs.attachmentId that is empty, whitespace-only, a numeric database ID, a truncated/copied-partial UUID, or a value with surrounding characters instead of a canonical UUID string.","commonSituations":"Copying only part of the attachment ID from a UI URL; passing an integer row ID from a database export; forgetting the argument entirely (empty string after trim); pasting an ID wrapped in quotes or with trailing whitespace/newline.","solutions":["Re-copy the full UUID of the attachment (8-4-4-4-12 hex format) and pass it again","Check you are using the attachment's UUID, not its numeric ID or filename","Trim surrounding quotes/whitespace from the argument in your shell invocation","Run the list command (same CLI) to get valid attachmentIds with their columns"],"exampleFix":"// before\nnode cli attachment-download --attachmentId 12345\n// after\nnode cli attachment-download --attachmentId 550e8400-e29b-41d4-a716-446655440000","handlingStrategy":"validation","validationCode":"const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nif (!UUID_RE.test(String(id ?? '').trim())) {\n  throw new Error('attachmentId must be a canonical UUID');\n}","typeGuard":"const isUuid = (v) => typeof v === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v.trim());","tryCatchPattern":null,"preventionTips":["Copy full UUIDs from the list command output, not partial URL fragments","Do not substitute numeric database IDs for attachment UUIDs","Quote UUID arguments in shells that interpret dashes or special characters","Validate IDs in scripts before invoking the CLI to fail fast"],"tags":["cli","validation","arguments","uuid"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}