influxdata/influxdb · error · Error

missing query parameter 'q'

Error message

missing query parameter 'q'

What it means

This error is specific to the v1 /query compatibility API: the request included (or implied) a database but omitted the required `q` parameter holding the InfluxQL/SQL query text. The server distinguishes this narrower case from the combined missing 'db and q' error so clients get a precise message.

Solutions

  1. Add the `q` parameter: /query?db=mydb&q=SELECT ... (URL-encoded).
  2. Verify `q` is non-empty after interpolation and encoding; check shell quoting around the URL.
  3. If using a client library, pass the query through its query API rather than hand-building the URL.
  4. Consider using the v3 query endpoints (/api/v3/query_sql) if you are not relying on v1 compatibility.

Example fix

// before
let url = "http://localhost:8181/query?db=metrics";
// after
let url = "http://localhost:8181/query?db=metrics&q=SELECT%20*%20FROM%20cpu";
Defensive patterns

Strategy: validation

Validate before calling

fn validate_v1_query(db: &str, q: &str) -> Result<(), String> {
    if q.trim().is_empty() { Err("missing query parameter 'q'".into()) }
    else if db.trim().is_empty() { Err("missing query parameter 'db'".into()) }
    else { Ok(()) }
}

Prevention

When it happens

Trigger: GET /query?db=mydb without `q`; a query string built where `q` was dropped or empty after encoding; client sending SQL in the POST body of an endpoint that only reads the `q` query parameter.

Common situations: Migration from InfluxDB 1.x tooling that passes the query differently; shell quoting stripping the q= value; generated URLs with an empty q after templating.

Related errors


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/61c299ae45812e51. Report an issue: GitHub.

Appendix: source

Thrown at influxdb3_server/src/http.rs:272

    /// The HTTP request method is not supported for this resource
    #[error("unsupported method")]
    UnsupportedMethod,

    /// Hyper serving error
    #[error("error serving http: {0}")]
    ServingHttp(#[from] hyper::Error),

    /// Missing parameters for query
    #[error("missing query parameters 'db'")]
    MissingDeleteDatabaseParams,

    /// Missing parameters for query
    #[error("missing query parameters 'db' and 'q'")]
    MissingQueryParams,

    /// Missing the `q` parameter in the v1 /query API
    #[error("missing query parameter 'q'")]
    MissingQueryV1Params,

    /// MIssing parameters for write
    #[error("missing query parameter 'db'")]
    MissingWriteParams,

    #[error("the mime type specified was not valid UTF8: {0}")]
    NonUtf8MimeType(#[from] FromUtf8Error),

    /// Serde decode error
    #[error("serde error: {0}")]
    SerdeUrlDecoding(#[from] serde_urlencoded::de::Error),

    /// Arrow error
    #[error("arrow error: {0}")]
    Arrow(#[from] arrow::error::ArrowError),

    /// Hyper error

View on GitHub (pinned to 06200ef96b)