jenkinsci/jenkins · error · IllegalArgumentException

No such job '{src}'; perhaps you meant '{nearest.getFullName

Error message

No such job '{src}'; perhaps you meant '{nearest.getFullName()}'?

What it means

IllegalArgumentException from the args4j GenericItemOptionHandler during option parsing: the named item could not be resolved as the requested type, and Items.findNearest found a suggestion. Note the prior ACL.as2(SYSTEM) block: if the item exists but the current user cannot see it, the code logs a WARNING and still reports 'no such job' — so this can be a permission problem, not just a typo.

Source

Thrown at core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java:75

    protected abstract Class<T> type();

    @Override public int parseArguments(Parameters params) throws CmdLineException {
        final Jenkins j = Jenkins.get();
        final String src = params.getParameter(0);
        T s = j.getItemByFullName(src, type());
        if (s == null) {
            final Authentication who = Jenkins.getAuthentication2();
            try (ACLContext acl = ACL.as2(ACL.SYSTEM2)) {
                Item actual = j.getItemByFullName(src);
                if (actual == null) {
                    LOGGER.log(Level.FINE, "really no item exists named {0}", src);
                } else {
                    LOGGER.log(Level.WARNING, "running as {0} could not find {1} of {2}", new Object[] {who.getPrincipal(), actual, type()});
                }
            }
            T nearest = Items.findNearest(type(), src, j);
            if (nearest != null) {
                throw new IllegalArgumentException("No such job '" + src + "'; perhaps you meant '" + nearest.getFullName() + "'?");
            } else {
                throw new IllegalArgumentException("No such job '" + src + "'");
            }
        }
        setter.addValue(s);
        return 1;
    }

    @Override public String getDefaultMetaVariable() {
        return "ITEM";
    }

}

View on GitHub (pinned to 2e228ff40b)

Solutions

  1. Authenticate the CLI as a user with READ on the item (API token / login).
  2. Use the suggested full name.
  3. Supply the fully-qualified name including the folder path.
Defensive patterns

Strategy: validation

Validate before calling

Item it;
try (ACLContext ctx = ACL.as2(ACL.SYSTEM2)) {
    it = Jenkins.get().getItemByFullName(name);
}
if (it == null) { /* truly absent vs. permission: re-check as current user */ }

Try / catch

catch (CmdLineException | IllegalArgumentException e) { /* item unresolved or not visible to user */ }

Prevention

When it happens

Trigger: Any CLI command taking an ITEM option (e.g. -j / positional JOB) with a name that is missing or invisible to the current user, where a near item exists.

Common situations: Running the CLI as a user without Job.READ on the item (item exists but reads as missing); typo; renamed job; cross-folder name without the full path.

Related errors


AI-assisted analysis of jenkinsci/jenkins@2e228ff40b (2026-08-14). Data as JSON: /api/errors/8df15c1e0906ac65. Report an issue: GitHub.