OtterMind/Chat2DB · warning · BusinessException

jsonFile.parse.error

jsonFile.parse.error

Error message

jsonFile.parse.error

What it means

BusinessException 'jsonFile.parse.error' from JSONImporter.getJsonNode when, after optional rootNodeName resolution, the target JsonNode is not an array or is an empty array. The importer expects the JSON content (or the named root) to be a non-empty array of row objects.

Source

Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/task/imports/json/JSONImporter.java:104

            if (Objects.isNull(columnValueNode)) {
                values.add(null);
            } else {
                SQLDataValue sqlDataValue = getSQLDataValue(columnValueNode.asText(), c);
                String value = valueProcessor.getSqlValueString(sqlDataValue);
                values.add(value);
            }
        }
        return values;
    }


    @NotNull
    private JsonNode getJsonNode(String rootNodeName, JsonNode jsonNode) {
        if (StringUtils.isNotBlank(rootNodeName) && jsonNode.has(rootNodeName)) {
            jsonNode = jsonNode.get(rootNodeName);
        }
        if (!jsonNode.isArray() || jsonNode.size() <= 0) {
            throw new BusinessException("jsonFile.parse.error");
        }
        return jsonNode;
    }

}

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Ensure the JSON file (or the configured root node) is a non-empty array of row objects, e.g. [{...},{...}].
  2. Set the correct rootNodeName if rows are nested under a key (e.g. {"data":[...]} -> rootNodeName='data').
  3. Remove empty leading/trailing array entries and confirm the file is not truncated.

Example fix

// before
{"count":2}            // not an array -> throws
// after
[{"id":1},{"id":2}]     // non-empty array of rows
Defensive patterns

Strategy: validation

Validate before calling

JsonNode node = rootNodeName != null && root.has(rootNodeName) ? root.get(rootNodeName) : root;
if (!node.isArray() || node.size() == 0) throw new BusinessException("jsonFile.parse.error");

Type guard

boolean isNonEmptyArrayNode(com.fasterxml.jackson.databind.JsonNode n) {
    return n != null && n.isArray() && n.size() > 0;
}

Prevention

When it happens

Trigger: Importing a JSON file whose root (or named root node) is an object, a scalar, or an empty array; rootNodeName points at a non-array child; file is a JSON object wrapper without the rows array.

Common situations: File exported as a single object instead of array; empty file/array; wrong rootNodeName configured; JSON structure differs from the expected [{...},{...}] shape.

Related errors


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/e9940625ab5687b0. Report an issue: GitHub.