hasura/graphql-engine · error · Error

Error while building the request for the pre-response plugin

Error message

Error while building the request for the pre-response plugin {0} - {1}

What it means

The engine failed while constructing the HTTP request it sends to the pre-NDC-response plugin — before any network activity. The wrapped BuildRequestError details the exact cause: invalid header name, invalid header value, session conversion problems, or serialization failure. The plugin name is included for context.

Solutions

  1. Look at the wrapped BuildRequestError source to identify the real cause (header/session/serialization)
  2. Fix the offending config value or session variable as indicated by the inner error
  3. Re-deploy plugin and engine at matching versions
  4. Validate plugin config in CI with a schema check before rollout
Defensive patterns

Strategy: validation

Validate before calling

// validate all forwarded header names/values and session vars before enabling the hook
config.forward_headers.iter().for_each(|(k, v)| { assert!(valid_header_name(k)); assert!(ascii_header_value(v)); });

Try / catch

if let Err(Error::BuildRequestError(name, inner)) = res {
    tracing::error!(plugin = name, inner = ?inner, "hook request build failed");
}

Prevention

When it happens

Trigger: Config of the response plugin references headers or session variables that fail conversion, or the response payload cannot be serialized, while building the outgoing webhook request.

Common situations: Malformed forwarded-header config; session variables with unexpected shapes after an auth change; engine/plugin version skew altering the wire format.

Related errors


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

Appendix: source

Thrown at v3/crates/plugins/pre-ndc-response-plugin/src/execute.rs:18

use axum::http::HeaderName;
use engine_types::HttpContext;
use hasura_authn_core::{Role, Session, SessionVariableName};
use metadata_resolve::{DataConnectorLink, Qualified, ResolvedLifecyclePreNdcResponsePluginHook};
use open_dds::data_connector::DataConnectorName;
use reqwest::{
    Client,
    header::{InvalidHeaderName, InvalidHeaderValue},
};
use serde::{Deserialize, Serialize};
use std::{collections::BTreeMap, str::FromStr, sync::Arc};
use tracing_util::{ErrorVisibility, SpanVisibility, TraceableError, set_attribute_on_active_span};

#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("Error while making the HTTP request to the pre-response plugin {0} - {1}")]
    ErrorWhileMakingHTTPRequestToTheHook(String, reqwest::Error),
    #[error("Error while building the request for the pre-response plugin {0} - {1}")]
    BuildRequestError(String, #[source] BuildRequestError),
    #[error("Reqwest error: {0}")]
    ReqwestError(reqwest::Error),
    #[error("Unexpected status code: {0}")]
    UnexpectedStatusCode(u16),
    #[error("Error parsing the request: {0}")]
    PluginRequestParseError(serde_json::error::Error),
    #[error("Internal error from plugin {plugin_name}")]
    PluginInternalError {
        plugin_name: String,
        error: serde_json::Value,
    },
    #[error("User error from plugin {plugin_name}")]
    PluginUserError {
        plugin_name: String,
        error: serde_json::Value,
    },
}

View on GitHub (pinned to 724551b9ae)