JetBrains/intellij-community · error · BuildException

Invalid input: {input}

Error message

Invalid input: {input}

What it means

This BuildException is thrown by IntelliJ's Ant runtime InputHandler (IdeaInputHandler) while an Ant build waits for interactive input. The handler reads a length-prefixed input string from the IDE over the error stream, calls request.setInput(input), and then validates it via request.isInputValid(). If the Ant InputRequest's validator rejects the value, the build aborts with 'Invalid input: <what you typed>'. Standard Ant requests consider any non-null input valid, so this only fires when the build file uses a request type with a real validator (e.g. a multiple-choice or yes/no InputRequest created with valid input arguments).

Source

Thrown at java/java-runtime/src/com/intellij/rt/ant/execution/IdeaInputHandler.java:50

        for (String choice : choices) {
          packet.appendLimitedString(choice);
        }
      }
      else {
        packet.appendLong(0);
      }
    }
    else {
      packet.appendLong(0);
    }
    packet.sendThrough(err);
    try {
      final byte[] lengthValue = readBytes(4);
      final int length = (toUnsignedInt(lengthValue[0]) << 24) | (toUnsignedInt(lengthValue[1]) << 16) | (toUnsignedInt(lengthValue[2]) << 8) | toUnsignedInt(lengthValue[3]);
      final String input = new String(readBytes(length));
      request.setInput(input);
      if (!request.isInputValid()) {
        throw new BuildException("Invalid input: " + input);
      }
    }
    catch (IOException e) {
      throw new BuildException(e);
    }
  }

  private static int toUnsignedInt(final byte b) {
    return (int)b & 0xFF;
  }

  private static byte[] readBytes(int count) throws IOException {
    byte[] data = new byte[count];
    int read = System.in.read(data);
    if (read != count) {
      throw new IOException("End of input stream");
    }
    return data;

View on GitHub (pinned to be881553f2)

Solutions

  1. Re-run the build and answer the prompt with one of the exact values the build script declares as valid (check the validargs attribute of the <input> task in build.xml).
  2. Open the Ant build file, locate the <input> task that failed, and either add your expected answer to its validargs list or remove the restriction if any answer should be accepted.
  3. If the input you typed was correct, verify the IDE and the bundled intellij-rt Ant classes are from the same IntelliJ version (re-sync the Ant run configuration so the correct java-runtime classes are put on the classpath).
  4. For automated runs, feed a pre-decided value with Ant's -Dproperty or the usesprompt avoidance (set the property the <input> task writes via addproperty) so no interactive validation happens.

Example fix

<!-- before: only exact 'y'/'n' accepted, users type 'yes' -->
<input message="Continue?" validargs="y,n" addproperty="continue.answer"/>

<!-- after: accept common spellings -->
<input message="Continue?" validargs="y,yes,n,no" addproperty="continue.answer"/>
Defensive patterns

Strategy: validation

Validate before calling

// In build.xml, make every answer valid by construction: pre-set the property so the
// <input> task never blocks or rejects scripted runs:
//   ant -Dcontinue.answer=y  (input task with addproperty="continue.answer" is skipped)
// Or restrict and document valid answers next to the prompt:
//   <input message="Continue? (y/n)" validargs="y,n" addproperty="continue.answer"/>

Try / catch

// Wrap the Ant Project execution and surface input failures clearly:
try {
  project.executeTarget("ask-user");
} catch (BuildException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Invalid input:")) {
    // re-prompt or default; the user's answer failed the task's validargs check
    log.warn("Input rejected by <input validargs=...>: " + e.getMessage());
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: An Ant task (typically <input> with a custom InputRequest or one of Ant's validated request types) requests input while the build runs under IntelliJ's launcher; the user's answer fails the request's isInputValid() check (for example an answer not in the validargs list of a multiple-choice input handler request).

Common situations: Answering a multiple-choice <input validargs="y,n"> prompt with something else (e.g. 'yes' instead of 'y'); a build script whose validargs list does not match what users actually type; stale IDE-to-build process protocol after a version mismatch between the IDE and the com.intellij.rt.ant classes on the classpath; tests/CI automation sending unexpected stdin content to an interactive Ant build.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/35be40c16b197ba4. Report an issue: GitHub.