{"record":{"id":"f15efaa33f62c8dc","repo":"hasura/graphql-engine","slug":"error-parsing-the-request-0-f15efa","errorCode":null,"errorMessage":"Error parsing the request: {0}","messagePattern":"Error parsing the request: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/plugins/pre-parse-plugin/src/execute.rs","lineNumber":33,"sourceCode":"};\n\n/// HTTP status code used by pre-parse plugins to indicate they want to continue\n/// processing with a modified request body.\n///\n/// We use 299 (an unassigned 2xx status code) as a special signal for this.\nconst CONTINUE_WITH_REQUEST_STATUS: u16 = 299;\n\n#[derive(Debug, thiserror::Error)]\npub enum Error {\n    #[error(\"Error while making the HTTP request to the pre-parse plugin {0} - {1}\")]\n    ErrorWhileMakingHTTPRequestToTheHook(String, reqwest::Error),\n    #[error(\"Error while building the request for the pre-parse plugin {0} - {1}\")]\n    BuildRequestError(String, String),\n    #[error(\"Reqwest error: {0}\")]\n    ReqwestError(reqwest::Error),\n    #[error(\"Unexpected status code: {0}\")]\n    UnexpectedStatusCode(u16),\n    #[error(\"Error parsing the request: {0}\")]\n    PluginRequestParseError(serde_json::error::Error),\n}\n\nimpl Error {\n    pub fn is_internal(&self) -> bool {\n        match self {\n            Error::ErrorWhileMakingHTTPRequestToTheHook(_, _) | Error::UnexpectedStatusCode(_) => {\n                false\n            }\n            Error::BuildRequestError(_, _)\n            | Error::ReqwestError(_)\n            | Error::PluginRequestParseError(_) => true,\n        }\n    }\n\n    pub fn into_graphql_error(self) -> lang_graphql::http::GraphQLError {\n        lang_graphql::http::GraphQLError {\n            message: self.to_string(),","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/plugins/pre-parse-plugin/src/execute.rs#L15-L51","documentation":"Thrown when the JSON payload returned by (or sent to) the pre-parse hook fails to deserialize into the expected plugin request structure (serde_json::error::Error). This is a schema mismatch between what the engine serializes/expects and what the hook produces/expects.","triggerScenarios":"The hook returns a JSON body whose fields don't match the expected request type (missing fields, wrong types, trailing data), or the engine fails to parse the hook's instruction payload.","commonSituations":"Engine and plugin built from different versions with a changed schema; plugin returning an error JSON instead of the expected payload; a proxy injecting an HTML error page that gets parsed as JSON.","solutions":["Pin engine and plugin crates to compatible versions (schema contract).","Log the raw hook response body to see exactly what failed to parse.","If a proxy intercepts the hook, exclude the plugin route or fix the proxy's error responses.","Add tolerant serde attributes (Option fields, #[serde(default)]) on the plugin schema if you control it."],"exampleFix":"// before (strict, breaks when hook omits a field)\n#[derive(Deserialize)]\nstruct HookRequest { op: String, target: String }\n\n// after\n#[derive(Deserialize)]\nstruct HookRequest { op: String, #[serde(default)] target: Option<String> }","handlingStrategy":"validation","validationCode":"// hook side: verify payload matches before responding\nlet parsed: PluginRequest = serde_json::from_str(&body)\n    .map_err(|e| (http::StatusCode::BAD_REQUEST, e.to_string()));","typeGuard":null,"tryCatchPattern":"match serde_json::from_str::<PluginRequest>(&raw) {\n    Ok(r) => r,\n    Err(e) => { tracing::warn!(\"schema mismatch: {e}\"); fallback_default() }\n}","preventionTips":["Share the request/response types via a common crate between engine and hook.","Add golden-file JSON tests for the hook contract.","Log raw bodies on parse failure to speed diagnosis."],"tags":["json","serde","plugin","rust","pre-parse-hook"],"backgroundTag":"json-deserialization-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}