jenkinsci/jenkins · error · IllegalArgumentException

No such agent "{node_s}" exists.

Error message

No such agent "{node_s}" exists.

What it means

Thrown by the `offline-node` CLI command when Jenkins has no Computer for the given name and EditDistance.findNearest cannot suggest a close match. The message comes from Messages.Computer_NoSuchSlaveExistsWithoutAdvice. The same IllegalArgumentException is reused for both the with-advice and without-advice cases via a ternary at OfflineNodeCommand.java:72.

Source

Thrown at core/src/main/java/hudson/cli/OfflineNodeCommand.java:72

        return Messages.OfflineNodeCommand_ShortDescription();
    }

    @Override
    protected int run() throws Exception {
        boolean errorOccurred = false;
        final Jenkins jenkins = Jenkins.get();
        final HashSet<String> hs = new HashSet<>(nodes);
        List<String> names = null;

        for (String node_s : hs) {
            try {
                Computer computer = jenkins.getComputer(node_s);
                if (computer == null) {
                    if (names == null) {
                        names = ComputerSet.getComputerNames();
                    }
                    String adv = EditDistance.findNearest(node_s, names);
                    throw new IllegalArgumentException(adv == null ?
                            hudson.model.Messages.Computer_NoSuchSlaveExistsWithoutAdvice(node_s) :
                            hudson.model.Messages.Computer_NoSuchSlaveExists(node_s, adv));
                }
                computer.cliOffline(cause);
            } catch (Exception e) {
                if (hs.size() == 1) {
                    throw e;
                }

                stderr.println(node_s + ": " + e.getMessage());
                errorOccurred = true;
                continue;
            }
        }

        if (errorOccurred) {
            throw new AbortException(CLI_LISTPARAM_SUMMARY_ERROR_TEXT);
        }

View on GitHub (pinned to 2e228ff40b)

Solutions

  1. List valid agents first (`Jenkins.get().getComputers()` or the CLI `computer`/`node` listing) and copy the exact name.
  2. Correct the spelling/case of the agent name in your command or script.
  3. If the node was deleted, recreate it or drop it from the target list.
Defensive patterns

Strategy: validation

Validate before calling

Computer c = Jenkins.get().getComputer(nodeName);
if (c == null) {
    throw new IllegalArgumentException("No such agent: " + nodeName
        + ". Known: " + ComputerSet.getComputerNames());
}

Try / catch

try {
    computer.cliOffline(cause);
} catch (IllegalArgumentException e) {
    // name unknown; surface known names and continue
    stderr.println(nodeName + ": " + e.getMessage());
}

Prevention

When it happens

Trigger: Running `jenkins-cli offline-node <name>` (or offline-node with multiple names where one is invalid) where `Jenkins.getComputer(node_s)` returns null and no existing computer name is within edit distance of <name>.

Common situations: Typo in the agent name; the agent was deleted or renamed after the script was written; passing the built-in node name when an agent name is expected; a stale node list fed from an external inventory.

Related errors


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