appsmithorg/appsmith · error · AppsmithPluginException

PE-JSN-4000

PE-JSN-4000

Error message

Plugin failed to parse JSON "{0}"

What it means

Thrown by AnthropicPlugin.formatResponseBodyAsCompletionAPI when objectMapper.readValue(response, MessageDTO.class) raises IOException (AppsmithPluginError.PLUGIN_JSON_PARSE_ERROR, code PE-JSN-4000, message 'Plugin failed to parse JSON "{0}"'). The bytes returned by the Anthropic completion endpoint could not be deserialized into MessageDTO, and the raw response is interpolated into the message.

Source

Thrown at app/server/appsmith-plugins/anthropicPlugin/src/main/java/com/external/plugins/AnthropicPlugin.java:247

                        return Mono.just(errorResult);
                    });
        }

        /**
         * To keep things backward compatible, if model doesn't belong to claude 3, format response in form of claude completion API
         */
        private Object formatResponseBodyAsCompletionAPI(String model, byte[] response) {
            try {
                MessageDTO messageDTO = objectMapper.readValue(response, MessageDTO.class);
                CompletionDTO completionDTO = new CompletionDTO();
                completionDTO.setId(messageDTO.getId());
                completionDTO.setType("completion");
                completionDTO.setStopReason(messageDTO.getStopReason());
                completionDTO.setModel(model);
                completionDTO.setCompletion(messageDTO.getFirstMessage());
                return completionDTO;
            } catch (IOException e) {
                throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_JSON_PARSE_ERROR, new String(response));
            }
        }

        @Override
        public Mono<TriggerResultDTO> trigger(
                APIConnection connection, DatasourceConfiguration datasourceConfiguration, TriggerRequestDTO request) {
            log.debug(Thread.currentThread().getName() + ": trigger() called for Anthropic plugin.");
            final ApiKeyAuth apiKeyAuth = (ApiKeyAuth) datasourceConfiguration.getAuthentication();
            if (!StringUtils.hasText(apiKeyAuth.getValue())) {
                return Mono.error(new AppsmithPluginException(
                        AppsmithPluginError.PLUGIN_DATASOURCE_ARGUMENT_ERROR, EMPTY_API_KEY));
            }
            if (!StringUtils.hasText(request.getRequestType())) {
                throw new AppsmithPluginException(
                        AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "request type is missing");
            }
            String requestType = request.getRequestType();

View on GitHub (pinned to 8cd9021c24)

Solutions

  1. Inspect the {0} payload in the error — it is the raw Anthropic response, which usually reveals the real cause (auth error, model not found, rate limit).
  2. Verify the API key is valid and has access to the requested model.
  3. Confirm the model id and API version used by the plugin match a currently supported Anthropic model.
  4. Retry on transient 429/5xx; check the Appsmith plugin version supports the current Anthropic API schema.

Example fix

// The {0} in the message IS the raw response — read it:
// e.g. {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}
// -> fix the API key in the datasource and re-run.
Defensive patterns

Strategy: try-catch

Validate before calling

// Cannot validate the remote response shape pre-call, but you can pre-check inputs:
if (!this.datasourceConfig.apiKey) throw new Error('Anthropic API key is required');
if (!this.params.model) throw new Error('A valid Anthropic model id is required');

Try / catch

// Catch the PLUGIN_JSON_PARSE_ERROR and read the {0} raw-response payload:
// it usually contains Anthropic's own error JSON (authentication_error,
// not_found_error, rate_limit_error). Branch on that to guide the user.

Prevention

When it happens

Trigger: The Anthropic API returned a body that is not the expected MessageDTO JSON — e.g. an HTML error page, an error JSON shape (error.object) rather than a success message, an empty body, or a schema change in the Anthropic API that MessageDTO does not model. The catch rethrows with new String(response) as the {0} argument.

Common situations: Invalid/expired API key causing an auth error body; rate-limit (429) returning a non-message body; Anthropic API version change; network proxy injecting an error page; model name typo returning an API error response.

Understand the failure class

Related errors


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