hasura/graphql-engine · error · BuildRequestError

Serialization error: {0}

Error message

Serialization error: {0}

What it means

A generic serde_json failure raised while serializing the request payload for the pre-NDC-request plugin (this variant is #[from] serde_json::Error). It means the request struct could not be turned into JSON at all — typically a non-string map key or a type that serde_json cannot represent. Distinct from PluginRequestParseError, which is about parsing the response.

Source

Thrown at v3/crates/plugins/pre-ndc-request-plugin/src/execute.rs:59

    InvalidHeaderName {
        header_name: String,
        #[source]
        error: InvalidHeaderName,
    },
    #[error("Invalid header value for header {header_name}: {error}")]
    InvalidHeaderValue {
        header_name: HeaderName,
        #[source]
        error: InvalidHeaderValue,
    },
    #[error("Failed to convert session: {0}")]
    SessionConversionError(String),
    #[error("Failed to convert session variable '{variable_name}': {error}")]
    SessionVariableConversionError {
        variable_name: SessionVariableName,
        error: serde_json::Error,
    },
    #[error("Serialization error: {0}")]
    SerializationError(#[from] serde_json::Error),
}

impl TraceableError for Error {
    fn visibility(&self) -> ErrorVisibility {
        match self {
            Error::BuildRequestError(_, _) => ErrorVisibility::Internal,
            Error::PluginUserError { .. }
            | Error::ReqwestError(_)
            | Error::PluginRequestParseError(_)
            | Error::ErrorWhileMakingHTTPRequestToTheHook(_, _)
            | Error::UnexpectedStatusCode(_)
            | Error::PluginInternalError { .. } => ErrorVisibility::User,
        }
    }
}

#[derive(Deserialize, Debug, Clone)]

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Enable debug logging of the outgoing request to find which field fails to serialize
  2. Ensure any custom map keys are strings and values are JSON-representable
  3. Align engine and plugin crate versions so the request struct serializes cleanly
  4. Simplify the request (remove custom extensions) to isolate the failing field
Defensive patterns

Strategy: try-catch

Validate before calling

let probe = serde_json::to_value(&sample_request)?; // catches bad Serialize early in tests

Try / catch

match serde_json::to_value(&req) {
    Ok(v) => v,
    Err(e) => return Err(Error::SerializationError(e)),
}

Prevention

When it happens

Trigger: serde_json::to_value / to_string on the outgoing request fails inside build_request, e.g. a serialized map with a non-string key or a Serialize impl that errors.

Common situations: Custom connector or plugin code adding non-JSON-representable values to the request; engine/plugin version skew changing request types; bugs in a custom Serialize implementation.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/0d50046dd2ab2525. Report an issue: GitHub.