appsmithorg/appsmith · error · AppsmithPluginException

PE-DSE-5003

PE-DSE-5003

Error message

Unable to parse content. Expected an array or object of multipart data

What it means

Thrown by DataUtils while building a multipart/form-data body when a part of type FILE triggers an IOException inside populateFileTypeBodyBuilder. The stack trace is printed via e.printStackTrace() (an anti-pattern) and the error is re-thrown as PLUGIN_DATASOURCE_ARGUMENT_ERROR with ERROR_INVALID_MULTIPART_DATA. The exception covers any I/O failure while materializing the file part, not just structural multipart problems.

Source

Thrown at app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/restApiUtils/helpers/DataUtils.java:237

                final MultipartFormDataType multipartFormDataType =
                        MultipartFormDataType.valueOf(property.getType().toUpperCase(Locale.ROOT));

                switch (multipartFormDataType) {
                    case TEXT:
                        byte[] valueBytesArray = new byte[0];
                        if (StringUtils.hasLength(String.valueOf(property.getValue()))) {
                            valueBytesArray =
                                    String.valueOf(property.getValue()).getBytes(StandardCharsets.ISO_8859_1);
                        }
                        bodyBuilder.part(key, valueBytesArray, MediaType.TEXT_PLAIN);
                        break;
                    case FILE:
                        try {
                            populateFileTypeBodyBuilder(bodyBuilder, property, outputMessage);
                        } catch (IOException e) {
                            e.printStackTrace();
                            throw new AppsmithPluginException(
                                    AppsmithPluginError.PLUGIN_DATASOURCE_ARGUMENT_ERROR, ERROR_INVALID_MULTIPART_DATA);
                        }
                        break;
                    case ARRAY:
                        if (property.getValue() instanceof String) {
                            final String value = (String) property.getValue();
                            try {
                                final JsonNode jsonNode = objectMapper.readTree(value);
                                if (jsonNode.isArray()) {
                                    for (JsonNode node : jsonNode) {
                                        if (node.isTextual()) bodyBuilder.part(key, node.asText());
                                        else bodyBuilder.part(key, node);
                                    }
                                } else {
                                    bodyBuilder.part(key, value);
                                }
                            } catch (JsonProcessingException e) {
                                bodyBuilder.part(key, value);

View on GitHub (pinned to 8cd9021c24)

Solutions

  1. Inspect the server log for the printStackTrace output of the underlying IOException - it names the real cause.
  2. Verify the FILE part value is a well-formed data URL (data:<mime>;base64,<content>) or a valid base64 string.
  3. If binding from a FilePicker, confirm the file is still present and not cleared before the action runs.
  4. Replace the e.printStackTrace() call with a proper log.error so future failures are diagnosable.

Example fix

// before
} catch (IOException e) {
    e.printStackTrace();
    throw new AppsmithPluginException(
        AppsmithPluginError.PLUGIN_DATASOURCE_ARGUMENT_ERROR, ERROR_INVALID_MULTIPART_DATA);
}

// after
} catch (IOException e) {
    log.error("Failed to build multipart FILE part for key {}", key, e);
    throw new AppsmithPluginException(
        AppsmithPluginError.PLUGIN_DATASOURCE_ARGUMENT_ERROR,
        ERROR_INVALID_MULTIPART_DATA + ": " + e.getMessage(), e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// For FILE-type multipart parts, validate the value is a usable data URL or base64
Object v = property.getValue();
if (v instanceof String) {
    String s = (String) v;
    if (s.startsWith("data:") && !s.contains(";base64,")) {
        throw new IllegalArgumentException("FILE part value is a data URL without base64 encoding");
    }
}

Type guard

public static boolean looksLikeFilePart(Object v) {
    if (!(v instanceof String)) return false;
    String s = (String) v;
    return s.startsWith("data:") && s.contains(";base64,");
}

Try / catch

try {
    bodyData = dataUtils.parseRequestBody(contentType, body, encodeParams);
} catch (AppsmithPluginException e) {
    if (e.getMessage() != null && e.getMessage().contains(ERROR_INVALID_MULTIPART_DATA)) {
        log.error("Multipart FILE part failed to build", e);
        throw new IllegalArgumentException("Failed to build multipart FILE part; check file content", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: A multipart action with a FILE part whose value cannot be read or written: a base64 data URL that decodes to nothing, a file reference pointing to non-existent content, a stream that throws during copy to the output message, or an invalid base64 payload.

Common situations: Binding a FilePicker widget's files array into a multipart FILE field where the data URL is malformed; an API action referencing a file that was cleared from the Appsmith store; large-file uploads hitting a size/encoding issue.

Understand the failure class

Related errors


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