pentaho/pentaho-kettle · error · IllegalArgumentException

Invalid schema JSON:

Error message

Invalid schema JSON: 

What it means

AvroSchemaValidator.validateSchema parses the schema string with Jackson (mapper.readTree) and wraps any parse failure (or non-IllegalArgumentException failure) in an IllegalArgumentException prefixed with "Invalid schema JSON: ". It means the string is not syntactically valid JSON and cannot be treated as an Avro schema.

Solutions

  1. Read the wrapped e.getMessage() after the prefix — Jackson reports the exact line/offset of the syntax error.
  2. Validate the schema string with any JSON linter/parser and fix the syntax error.
  3. If referencing a file, read the .avsc file's contents, not the path, before validating.
  4. Confirm the variable/parameter substitution did not truncate or mangle the JSON.

Example fix

// before
String schema = "/schemas/user.avsc";
AvroSchemaValidator.validateSchema(schema); // Invalid schema JSON: ...
// after
String schema = Files.readString(Path.of("/schemas/user.avsc"));
AvroSchemaValidator.validateSchema(schema);
Defensive patterns

Strategy: validation

Validate before calling

public static void requireValidJson(String s) {
  try { new com.fasterxml.jackson.databind.ObjectMapper().readTree(s); }
  catch (Exception e) { throw new IllegalArgumentException("Not valid JSON: " + e.getMessage()); }
}

Try / catch

try {
  AvroSchemaValidator.validateSchema(schemaString);
} catch (IllegalArgumentException e) {
  if (e.getMessage().startsWith("Invalid schema JSON:")) {
    logger.error("Fix JSON syntax: " + e.getMessage());
  }
  throw e;
}

Prevention

When it happens

Trigger: validateSchema is given a string that is not valid JSON — trailing commas, single quotes, unquoted keys, truncated JSON, or content like a file path or Avro IDL instead of the JSON schema.

Common situations: User pasted an .avsc file path instead of its contents; schema was truncated by a size limit; hand-edited JSON with syntax errors; wrong quoting when embedding the schema in a variable or properties file.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/9f13223eca5da534. Report an issue: GitHub.

Appendix: source

Thrown at plugins/avro-format/core/src/main/java/org/pentaho/di/trans/steps/avro/AvroSchemaValidator.java:66

   * Validates a schema string for potential code injection vulnerabilities.
   * 
   * @param schemaString the schema JSON string to validate
   * @throws IllegalArgumentException if the schema contains suspicious patterns
   */
  public static void validateSchema(String schemaString) throws IllegalArgumentException {
    if (schemaString == null || schemaString.isEmpty()) {
      throw new IllegalArgumentException("Schema string cannot be null or empty");
    }

    try {
      JsonNode schemaNode = mapper.readTree(schemaString);
      if (schemaNode.isObject()) {
        validateSchemaNode((ObjectNode) schemaNode);
      }
    } catch (IllegalArgumentException e) {
      throw e;
    } catch (Exception e) {
      throw new IllegalArgumentException("Invalid schema JSON: " + e.getMessage(), e);
    }
  }

  /**
   * Validates a schema node and all its fields for injection patterns.
   * 
   * @param node the schema node to validate
   * @throws IllegalArgumentException if suspicious patterns are found
   */
  private static void validateSchemaNode(ObjectNode node) throws IllegalArgumentException {
    Iterator<String> fieldNames = node.fieldNames();
    
    while (fieldNames.hasNext()) {
      String fieldName = fieldNames.next();
      JsonNode fieldValue = node.get(fieldName);

      // Check doc field specifically, as it's the vector for CVE-2025-33042
      if ("doc".equalsIgnoreCase(fieldName) && fieldValue != null) {

View on GitHub (pinned to f3058517a1)