affaan-m/ECC · error · Error

Arguments must not contain NUL bytes.

Error message

Arguments must not contain NUL bytes.

What it means

validateArgv iterates every argument intended for the spawned process and rejects any containing a NUL byte. NUL cannot appear in OS argv entries, so passing one would cause the spawn call to fail obscurely; the script surfaces a clear error instead.

Solutions

  1. Sanitize each argument with `arg.replace(/\0/g, '')` before calling.
  2. Trace and fix the upstream source producing the NUL byte.
  3. Validate argv contents programmatically before invoking the script.

Example fix

// before
const argv = ['--', rawArgFromBuffer];
// after
const argv = ['--', rawArgFromBuffer.replace(/\0/g, '')];
Defensive patterns

Strategy: validation

Validate before calling

const clean = (args) => { args.forEach(a => { if (typeof a !== 'string' || a.includes('\0')) throw new Error('argv entries must be NUL-free strings'); }); return args; };

Type guard

function isNulFreeArgv(args) {
  return Array.isArray(args) && args.every(a => typeof a === 'string' && !a.includes('\0'));
}

Try / catch

try {
  parseArgs(process.argv);
} catch (e) {
  if (/must not contain NUL bytes/.test(e.message)) {
    console.error('An argument contains a NUL byte; sanitize the value source');
  } else throw e;
}

Prevention

When it happens

Trigger: Programmatic callers building the post-`--` argument list from buffers, JSON with `\u0000`, or string truncation bugs that left a NUL in an argument.

Common situations: Reading args from binary config data; template engines inserting control characters; inter-process data passed through fixed-size C buffers that NUL-pad strings.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/3e28f5f6337e3f8c. Report an issue: GitHub.

Appendix: source

Thrown at skills/terminal-opener/scripts/open-terminal.js:76

  const firstSeparatorIndex = separatorIndexes.length > 0 ? Math.min(...separatorIndexes) : -1;
  const resemblesExecutablePath = isAbsolutePath(value)
    || (firstSeparatorIndex >= 0 && (whitespaceIndex < 0 || firstSeparatorIndex < whitespaceIndex));

  if (whitespaceIndex >= 0 && !resemblesExecutablePath) {
    throw new Error(
      'Executable must be one argv entry, not an interpolated shell command string.'
    );
  }
  if (!resemblesExecutablePath && /[;&|<>`$]/.test(value)) {
    throw new Error(
      'Executable must be one argv entry, not an interpolated shell command string.'
    );
  }
}

function validateArgv(argv) {
  for (const argument of argv) {
    if (argument.includes('\0')) throw new Error('Arguments must not contain NUL bytes.');
  }
}

function readValue(argv, index, option) {
  const value = argv[index + 1];
  if (value === undefined || value.startsWith('--')) {
    throw new Error(`Missing value for ${option}.`);
  }
  return value;
}

function parseArgs(argv, context = {}) {
  const env = context.env || process.env;
  const initialTerminal = env.ECC_TERMINAL || DEFAULT_TERMINAL;
  const initialCwd = context.cwd || process.cwd();
  const options = {
    argv: [],
    cwd: initialCwd,

View on GitHub (pinned to 8321021c54)