jackwener/OpenCLI · error · ArgumentError

boss security-id contains unsupported characters

Error message

boss security-id contains unsupported characters

What it means

`opencli boss detail` validates the `security-id` argument against /^[A-Za-z0-9_-]+$/ before building the job-detail URL https://www.zhipin.com/job_detail/<id>.html. If the value contains spaces, slashes, full-width characters, or a full job URL, the command refuses to proceed with an ArgumentError. This guards against users pasting URLs or mangled IDs that would produce an invalid request.

Source

Thrown at clis/boss/detail.js:179

    navigateBefore: false,
    browser: true,
    defaultWindowMode: 'background',
    siteSession: 'persistent',
    args: [
        { name: 'security-id', positional: true, required: true, help: 'Security ID from search results (security_id field)' },
    ],
    columns: [
        'name', 'salary', 'experience', 'degree',
        'city', 'address',
        'description', 'skills', 'welfare',
        'boss_name', 'boss_title', 'active_time',
        'company', 'industry', 'scale', 'stage', 'url',
    ],
    func: async (page, kwargs) => {
        requirePage(page);
        const jobId = readRequiredString(kwargs['security-id'], 'security-id');
        if (!/^[A-Za-z0-9_-]+$/.test(jobId)) {
            throw new ArgumentError('boss security-id contains unsupported characters', 'Pass the security_id returned by `opencli boss search`');
        }
        verbose('Fetching job detail from the rendered BOSS page...');
        return [await captureJobDetail(page, jobId)];
    },
});

export const __test__ = { cleanText, domSnapshotToRow };

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run `opencli boss search` again and copy the `security_id` field exactly as printed, not the job URL.
  2. Strip whitespace and quotes from the value before passing it (e.g. echo -n "$ID" | tr -d ' "').
  3. If you only have a job URL, extract the segment after /job_detail/ and before .html and pass that.
  4. Check your shell history/alias for extra flags or characters appended to the id.

Example fix

// before
opencli boss detail "https://www.zhipin.com/job_detail/abcDEF123.html"
// after
opencli boss detail abcDEF123
Defensive patterns

Strategy: validation

Validate before calling

const securityId = process.argv[2];
if (!/^[A-Za-z0-9_-]+$/.test(securityId)) {
  throw new Error(`Invalid security-id: ${securityId}. Use the security_id from 'opencli boss search'.`);
}

Type guard

function isValidSecurityId(v) {
  return typeof v === 'string' && /^[A-Za-z0-9_-]+$/.test(v);
}

Try / catch

try {
  await run(['opencli', 'boss', 'detail', securityId]);
} catch (e) {
  if (e.message.includes('unsupported characters')) {
    console.error('Re-run `opencli boss search` and pass its security_id field verbatim.');
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling `opencli boss detail` with a security-id that is not a plain BOSS security_id string — e.g. pasting the whole job_detail URL, an id wrapped in quotes/spaces, a full-width character id, or using a numeric job id from another source instead of the security_id from `opencli boss search`.

Common situations: Copy-pasting the job URL instead of the security_id field from search output; shell quoting adding stray characters; trimming/copy errors that pick up trailing whitespace or newline; using an id from a different BOSS API surface that uses a different id format.

Related errors


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