apache/seatunnel · error · IllegalArgumentException

Invalid metricType '%s' for column '%s'. Valid values are: %

Error message

Invalid metricType '%s' for column '%s'. Valid values are: %s

What it means

VectorIndex.parseMetricType validates the metricType string via MetricType.of(); unsupported values are rethrown as IllegalArgumentException with the column name and all valid MetricType values. Blank/null metric types are permitted (return null), so the throw only happens for invalid non-empty strings.

Source

Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/VectorIndex.java:134

        try {
            return IndexType.of(indexType);
        } catch (IllegalArgumentException exception) {
            throw new IllegalArgumentException(
                    String.format(
                            "Invalid indexType '%s' for column '%s'. Valid values are: %s",
                            indexType, columnName, Arrays.toString(IndexType.values())),
                    exception);
        }
    }

    private static MetricType parseMetricType(String metricType, String columnName) {
        if (metricType == null || metricType.trim().isEmpty()) {
            return null;
        }
        try {
            return MetricType.of(metricType);
        } catch (IllegalArgumentException exception) {
            throw new IllegalArgumentException(
                    String.format(
                            "Invalid metricType '%s' for column '%s'. Valid values are: %s",
                            metricType, columnName, Arrays.toString(MetricType.values())),
                    exception);
        }
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Use a metric type string exactly matching one of the values in the error message (MetricType.values())
  2. Fix casing/typos and trim whitespace
  3. Check your SeaTunnel version — the metric may not be supported yet; upgrade or pick a supported one

Example fix

// before
new VectorIndex("idx", "vec", "HNSW", "cosine_sim");
// after
new VectorIndex("idx", "vec", "HNSW", "COSINE"); // value from MetricType.values()
Defensive patterns

Strategy: validation

Validate before calling

boolean valid = Arrays.stream(MetricType.values()).anyMatch(t -> t.name().equalsIgnoreCase(metricType.trim()));
if (metricType != null && !metricType.trim().isEmpty() && !valid) throw new IllegalArgumentException("Bad metricType: " + metricType);

Try / catch

try { idx = new VectorIndex(name, col, indexType, metric); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Fix metricType for column " + col + ": " + e.getMessage(), e); }

Prevention

When it happens

Trigger: Constructing VectorIndex(name, column, indexType, metricType) where metricType is a non-blank string not in MetricType.values() (e.g. "cosine" vs "COSINE", or a metric not supported by this library version).

Common situations: Vector index configs copied from Milvus/other vector DB docs using metric names this library spells differently, wrong case, or newer metric types added upstream but not yet in the local version.

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 apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/10d60086f1d3f2e0. Report an issue: GitHub.