{"record":{"id":"6dd92668d9932a9f","repo":"appsmithorg/appsmith","slug":"pe-jsn-4000-6dd926","errorCode":"PE-JSN-4000","errorMessage":"Plugin failed to parse JSON \"{0}\"","messagePattern":"Plugin failed to parse JSON \"(.+?)\"","errorType":"exception","errorClass":"AppsmithPluginException","httpStatus":500,"severity":"error","filePath":"app/server/appsmith-plugins/anthropicPlugin/src/main/java/com/external/plugins/AnthropicPlugin.java","lineNumber":247,"sourceCode":"                        return Mono.just(errorResult);\n                    });\n        }\n\n        /**\n         * To keep things backward compatible, if model doesn't belong to claude 3, format response in form of claude completion API\n         */\n        private Object formatResponseBodyAsCompletionAPI(String model, byte[] response) {\n            try {\n                MessageDTO messageDTO = objectMapper.readValue(response, MessageDTO.class);\n                CompletionDTO completionDTO = new CompletionDTO();\n                completionDTO.setId(messageDTO.getId());\n                completionDTO.setType(\"completion\");\n                completionDTO.setStopReason(messageDTO.getStopReason());\n                completionDTO.setModel(model);\n                completionDTO.setCompletion(messageDTO.getFirstMessage());\n                return completionDTO;\n            } catch (IOException e) {\n                throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_JSON_PARSE_ERROR, new String(response));\n            }\n        }\n\n        @Override\n        public Mono<TriggerResultDTO> trigger(\n                APIConnection connection, DatasourceConfiguration datasourceConfiguration, TriggerRequestDTO request) {\n            log.debug(Thread.currentThread().getName() + \": trigger() called for Anthropic plugin.\");\n            final ApiKeyAuth apiKeyAuth = (ApiKeyAuth) datasourceConfiguration.getAuthentication();\n            if (!StringUtils.hasText(apiKeyAuth.getValue())) {\n                return Mono.error(new AppsmithPluginException(\n                        AppsmithPluginError.PLUGIN_DATASOURCE_ARGUMENT_ERROR, EMPTY_API_KEY));\n            }\n            if (!StringUtils.hasText(request.getRequestType())) {\n                throw new AppsmithPluginException(\n                        AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, \"request type is missing\");\n            }\n            String requestType = request.getRequestType();\n","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/appsmithorg/appsmith/blob/8cd9021c24cdbea1c3c12c966073708e83db60c2/app/server/appsmith-plugins/anthropicPlugin/src/main/java/com/external/plugins/AnthropicPlugin.java#L229-L265","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","Verify the API key is valid and has access to the requested model.","Confirm the model id and API version used by the plugin match a currently supported Anthropic model.","Retry on transient 429/5xx; check the Appsmith plugin version supports the current Anthropic API schema."],"exampleFix":"// The {0} in the message IS the raw response — read it:\n// e.g. {\"type\":\"error\",\"error\":{\"type\":\"authentication_error\",\"message\":\"invalid x-api-key\"}}\n// -> fix the API key in the datasource and re-run.","handlingStrategy":"try-catch","validationCode":"// Cannot validate the remote response shape pre-call, but you can pre-check inputs:\nif (!this.datasourceConfig.apiKey) throw new Error('Anthropic API key is required');\nif (!this.params.model) throw new Error('A valid Anthropic model id is required');","typeGuard":null,"tryCatchPattern":"// Catch the PLUGIN_JSON_PARSE_ERROR and read the {0} raw-response payload:\n// it usually contains Anthropic's own error JSON (authentication_error,\n// not_found_error, rate_limit_error). Branch on that to guide the user.","preventionTips":["Keep the Anthropic API key valid and scoped to the requested model.","Use a model id currently supported by the Anthropic API.","Upgrade the Appsmith Anthropic plugin to match the current API schema.","Inspect the raw response embedded in the error message first."],"tags":["java","appsmith","anthropic","plugin","json-parsing","jackson","api-error","llm"],"backgroundTag":null,"analyzedSha":"8cd9021c24cdbea1c3c12c966073708e83db60c2","analyzedAt":"2026-08-12T22:14:19.293Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}