conductor-oss/conductor · error · IllegalArgumentException

Invalid model format: '%s'. Expected 'provider/model'.

Error message

Invalid model format: '%s'. Expected 'provider/model'.

What it means

ModelParser.parse requires exactly one '/' separating a non-empty provider and a non-empty model. This error fires when there is no slash, the slash is at the start (empty provider), or the slash is at the end (empty model). The input must match the 'provider/model' shape.

Source

Thrown at common/src/main/java/org/conductoross/conductor/common/metadata/agent/ModelParser.java:45

        private String provider;
        private String model;
    }

    /**
     * Parse a model string like "openai/gpt-4o" into provider and model.
     *
     * @param modelString The model string in "provider/model" format.
     * @return A ParsedModel with provider and model components.
     * @throws IllegalArgumentException if the format is invalid.
     */
    public static ParsedModel parse(String modelString) {
        if (modelString == null || modelString.isBlank()) {
            throw new IllegalArgumentException("Model string cannot be null or empty");
        }

        int slashIdx = modelString.indexOf('/');
        if (slashIdx <= 0 || slashIdx >= modelString.length() - 1) {
            throw new IllegalArgumentException(
                    "Invalid model format: '" + modelString + "'. Expected 'provider/model'.");
        }

        String provider = modelString.substring(0, slashIdx);
        String model = modelString.substring(slashIdx + 1);
        return new ParsedModel(provider, model);
    }
}

View on GitHub (pinned to cf7c3e4a8a)

Solutions

  1. Format the model string as 'provider/model' with both segments non-empty (e.g. 'openai/gpt-4o').
  2. Add the provider prefix if only a bare model name was supplied.
  3. Validate the format (presence and position of '/') before calling parse.

Example fix

// before: missing provider prefix - rejected
ParsedModel m = ModelParser.parse("gpt-4o");

// after: full provider/model form
ParsedModel m = ModelParser.parse("openai/gpt-4o");
Defensive patterns

Strategy: validation

Validate before calling

// Validate 'provider/model' shape before parsing
static boolean isValidModelFormat(String s) {
    if (s == null || s.isBlank()) return false;
    int i = s.indexOf('/');
    return i > 0 && i < s.length() - 1;
}
if (!isValidModelFormat(modelString)) {
    throw new IllegalArgumentException(
        "model must be 'provider/model', got: " + modelString);
}

Type guard

// Narrow to a well-formed provider/model string
static boolean isValidModelString(String s) {
    return s != null && !s.isBlank()
        && s.indexOf('/') > 0 && s.indexOf('/') < s.length() - 1;
}

Try / catch

// Catch format errors and report the offending value
try {
    return ModelParser.parse(modelString);
} catch (IllegalArgumentException e) {
    throw new BadRequestException(
        "Invalid model '" + modelString + "'; expected 'provider/model'", e);
}

Prevention

When it happens

Trigger: Calling ModelParser.parse with a string like 'gpt-4o' (no slash), '/gpt-4o' (empty provider), 'openai/' (empty model), or 'openai' (no slash).

Common situations: Configuring just a model name without the provider prefix; a trailing slash typo; copy-paste that drops the provider segment; a default that only sets the model half.

Related errors


AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14). Data as JSON: /api/errors/692b3b8180eea280. Report an issue: GitHub.