jackwener/OpenCLI · error · ArgumentError

Refusing to write local Pixiv downloads: pass --execute

Error message

Refusing to write local Pixiv downloads: pass --execute

What it means

This ArgumentError is thrown by requireExecute in clis/pixiv/bookmark-download.js:26-30. The pixiv bookmark-download command runs in a dry-run mode by default and refuses to write files to disk unless --execute is explicitly passed. This is a safety gate so downloads only touch the local filesystem when the user intends it.

Source

Thrown at clis/pixiv/bookmark-download.js:28

  commitNovelFile,
  fetchNovelForDownload,
  normalizeNovelFileFormat,
  normalizePixivOutputRoot,
  pixivPathEntryExists,
  prepareNovelFile,
} from './novel-download-utils.js';

const IMAGE_CONTENT_TYPES = new Map([
  ['.jpg', 'image/jpeg'],
  ['.jpeg', 'image/jpeg'],
  ['.png', 'image/png'],
  ['.gif', 'image/gif'],
  ['.webp', 'image/webp'],
]);

function requireExecute(value) {
  if (value !== true) {
    throw new ArgumentError('Refusing to write local Pixiv downloads: pass --execute');
  }
}

function parsePixivImageUrl(value, label) {
  if (typeof value !== 'string' || !value) {
    throw new CommandExecutionError(`${label} returned a missing image URL`);
  }
  let url;
  try {
    url = new URL(value);
  } catch {
    throw new CommandExecutionError(`${label} returned a malformed image URL`);
  }
  const extension = path.extname(url.pathname).toLowerCase();
  const contentType = IMAGE_CONTENT_TYPES.get(extension);
  if (url.protocol !== 'https:' || url.hostname !== 'i.pximg.net' || url.username || url.password || url.port || !contentType) {
    throw new CommandExecutionError(`${label} returned an untrusted Pixiv image URL`);
  }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the command with the --execute flag
  2. Verify your wrapper/script passes --execute through to the underlying command
  3. Check the dry-run output first to confirm the planned downloads, then add --execute

Example fix

// before
opencli pixiv bookmark-download
// after
opencli pixiv bookmark-download --execute
Defensive patterns

Strategy: validation

Validate before calling

const args = process.argv.slice(2);
if (!args.includes('--execute')) {
  console.error('pixiv bookmark-download is dry-run only; pass --execute to write files.');
  process.exit(1);
}

Type guard

function willExecute(options) {
  return options === true || (typeof options === 'object' && options !== null && options.execute === true);
}

Try / catch

try {
  await runBookmarkDownload({ execute: true });
} catch (e) {
  if (e instanceof ArgumentError && e.message.includes('--execute')) {
    console.error('Dry-run refused to write files. Re-run with --execute.');
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Invoking the pixiv bookmark-download command (directly or via its CLI wrapper) without passing --execute, so requireExecute receives value !== true at clis/pixiv/bookmark-download.js:27.

Common situations: Running the command in a script or cron job and forgetting the --execute flag; assuming dry-run output already downloaded the files; an older wrapper or alias that omits the flag; copying an example invocation that only previews the plan.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/0a953187ce17b2fe. Report an issue: GitHub.