stanfordnlp/CoreNLP · error · IOException

Unhandled input format for scenegraph

Error message

Unhandled input format for scenegraph: ${inputFormat}

What it means

The scenegraph endpoint only supports plain text input. getSceneGraphRequest() throws IOException immediately if the inputFormat property is anything other than 'text', because scene-graph parsing has no other input decoders.

Solutions

  1. Request /scenegraph with inputFormat=text (or omit it, text is the default)
  2. Remove inputFormat from the properties passed to the scenegraph endpoint
  3. Pass the query via the 'q' property or the request body as plain text

Example fix

// before
props.setProperty("inputFormat", "serialized"); // scenegraph call
// after
props.remove("inputFormat"); // defaults to text for scenegraph
Defensive patterns

Strategy: validation

Validate before calling

if ("scenegraph".equals(endpoint)) {
  String in = props.getProperty("inputFormat", "text");
  if (!in.equals("text")) props.remove("inputFormat");
}

Try / catch

try {
  queryScenegraph(props, q);
} catch (IOException e) {
  if (e.getMessage().startsWith("Unhandled input format for scenegraph")) {
    props.remove("inputFormat");
    queryScenegraph(props, q);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the /scenegraph endpoint with properties containing inputFormat set to 'serialized', 'json', or any non-text value.

Common situations: Reusing the same properties block across endpoints (general pipeline requests allow serialized input, scenegraph does not); programmatic clients that always set inputFormat.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/b9ad8fce11e7c145. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java:385

        return defaultEncoding;
      }
    } else {
      return defaultEncoding;
    }
  }

  /**
   * Get a SceneGraph request from the query, either from a query parameter (q)
   * or from the body of the request
   * <br>
   * TODO: don't actually know if the scenegraph parser is threadsafe.
   *
   * @return query
   */
  private String getSceneGraphRequest(Properties props, HttpExchange httpExchange) throws IOException, ClassNotFoundException {
    final String inputFormat = props.getProperty("inputFormat", "text");
    if (!inputFormat.equals("text")) {
      throw new IOException("Unhandled input format for scenegraph: " + inputFormat);
    }
    String query = props.getProperty("q", null);
    if (query != null) {
      return query;
    }

    Headers headers = httpExchange.getRequestHeaders();
    // the original default behavior of the server was to
    // unescape, so let's assume by default that the input text is
    // escaped.  if the Content-type is set to text we will know
    // we shouldn't unescape after all
    final String contentType = getContentType(headers);
    // Get the encoding
    final String encoding = getEncoding(headers);

    String text = IOUtils.slurpReader(IOUtils.encodedInputStreamReader(httpExchange.getRequestBody(), encoding));
    if (contentType.equals(URL_ENCODED)) {
      try {

View on GitHub (pinned to 1b7edd19c4)