appsmithorg/appsmith · error · AppsmithPluginException

PE-ARG-5000

PE-ARG-5000

Error message

Query failed to execute because max token value is not an integer number

What it means

Thrown in CommandUtils.getMaxTokenFromFormData when parsing the max-token string throws an Exception that is NOT a NumberFormatException (NumberFormatException is caught first as IllegalArgumentException and returns DEFAULT_MAX_TOKEN). Only a non-numeric-parsing failure — e.g. extractValueFromFormData throwing, or a null/odd object type causing a different exception — reaches this throw. Code PE-ARG-5000.

Source

Thrown at app/server/appsmith-plugins/anthropicPlugin/src/main/java/com/external/plugins/utils/CommandUtils.java:53

            return gson.fromJson((String) messages.get(DATA), listType);
        }
        // return object stored in data key
        return (List<Map<String, String>>) messages.get(DATA);
    }

    public static int getMaxTokenFromFormData(Map<String, Object> formData) {
        String maxTokenAsString = RequestUtils.extractValueFromFormData(formData, MAX_TOKENS);

        if (!StringUtils.hasText(maxTokenAsString)) {
            return DEFAULT_MAX_TOKEN;
        }

        try {
            return Integer.parseInt(maxTokenAsString);
        } catch (IllegalArgumentException illegalArgumentException) {
            return DEFAULT_MAX_TOKEN;
        } catch (Exception exception) {
            throw new AppsmithPluginException(
                    AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR,
                    String.format(STRING_APPENDER, EXECUTION_FAILURE, BAD_MAX_TOKEN_CONFIGURATION));
        }
    }

    public static Float getTemperatureFromFormData(Map<String, Object> formData) {
        String temperatureString = RequestUtils.extractValueFromFormData(formData, TEMPERATURE);

        if (!StringUtils.hasText(temperatureString)) {
            return DEFAULT_TEMPERATURE;
        }

        try {
            return Float.parseFloat(temperatureString);
        } catch (IllegalArgumentException illegalArgumentException) {
            return DEFAULT_TEMPERATURE;
        } catch (Exception exception) {
            throw new AppsmithPluginException(

View on GitHub (pinned to 8cd9021c24)

Solutions

  1. Inspect the MAX_TOKENS field in formData — ensure it is a string or absent (absent yields DEFAULT_MAX_TOKEN).
  2. Remove any malformed/non-string entry in formData for the max-tokens slot.
  3. If reproducing programmatically, pass maxTokens as a numeric string (e.g. "1024").

Example fix

// before: non-string object causes extraction to throw
formData.put("maxTokens", List.of(1024));
// after
formData.put("maxTokens", "1024");
Defensive patterns

Strategy: validation

Validate before calling

// Pass maxTokens as a numeric string or omit it
Object raw = formData.get(MAX_TOKENS);
if (raw != null && !(raw instanceof String)) {
    formData.put(MAX_TOKENS, String.valueOf(raw));
}
// optionally validate parseability
String s = RequestUtils.extractValueFromFormData(formData, MAX_TOKENS);
if (StringUtils.hasText(s)) Integer.parseInt(s); // pre-check

Type guard

boolean isValidMaxToken(Object raw) {
    if (raw == null) return true;
    if (!(raw instanceof String s)) return false;
    if (!StringUtils.hasText(s)) return true;
    try { Integer.parseInt(s); return true; } catch (NumberFormatException e) { return false; }
}

Try / catch

try {
    int max = CommandUtils.getMaxTokenFromFormData(formData);
} catch (AppsmithPluginException e) {
    if (e.getMessage().contains("max token value is not an integer number")) {
        // reset maxTokens to a clean numeric string
    }
}

Prevention

When it happens

Trigger: The MAX_TOKENS form value is present but extractValueFromFormData raises an unexpected exception, or formData mutation produces a type that breaks extraction (not a simple unparseable number — that returns the default).

Common situations: Corrupted formData where the max-tokens entry is an unexpected object type; a plugin/RequestUtils version where extraction throws on malformed structures; concurrent modification of formData. A normal 'abc' value would NOT trigger this (it falls through to DEFAULT_MAX_TOKEN).

Related errors


AI-assisted analysis of appsmithorg/appsmith@8cd9021c24 (2026-08-12). Data as JSON: /api/errors/276f0c23a1462b2b. Report an issue: GitHub.