influxdata/influxdb · error · Error::InfluxqlSingleStatement
must provide only one InfluxQl statement per query
Error message
must provide only one InfluxQl statement per query
What it means
The v1 query API accepts exactly one InfluxQL statement per request. When the request body contains multiple statements, this unit variant is thrown. It exists to keep the API surface simple and the response mapping unambiguous.
Solutions
- Split the statements into separate /query requests.
- Strip the trailing/inner semicolons so only one statement remains.
- Update scripts or clients that batch multiple statements into one `q` value.
Example fix
// before GET /query?q=SELECT+*+FROM+a;SELECT+*+FROM+b // after GET /query?q=SELECT+*+FROM+a GET /query?q=SELECT+*+FROM+b
Defensive patterns
Strategy: validation
Validate before calling
function assertSingleStatement(q) {
const stmts = q.split(';').map(s => s.trim()).filter(Boolean);
if (stmts.length > 1) throw new Error(`expected 1 statement, got ${stmts.length}`);
return stmts[0] ?? '';
} Prevention
- Strip trailing semicolons from user-supplied query strings.
- Never batch multiple statements into a single `q` parameter.
- Write a unit test that rejects multi-statement payloads in client code.
When it happens
Trigger: POST to the v1 /query endpoint with a `q` parameter containing two or more statements separated by semicolons, e.g. `q=SELECT * FROM a; SELECT * FROM b`.
Common situations: Porting scripts from InfluxDB 1.x where multi-statement queries were allowed; copy-pasting multiple queries into one request; generated clients batching statements.
Understand the failure class
Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.
Related errors
- can only perform queries on a single database
- Database not found
- datafusion error
- error in InfluxQL statement
- error in InfluxQL statement
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/d09b8538de5f6ff9.
Report an issue: GitHub.
Appendix: source
Thrown at core/iox_v1_query_api/src/error.rs:55
message: &'static str,
error: String,
},
/// Serde decode error
#[error("error decoding params from url: {0}")]
SerdeUrlDecoding(#[from] serde_urlencoded::de::Error),
// SerdeJsonError
#[error("error decoding query body: {0}")]
SerdeJson(#[from] serde_json::Error),
#[error("datafusion error: {0}")]
Datafusion(#[from] DataFusionError),
#[error("error in InfluxQL statement: {0}")]
InfluxqlRewrite(#[from] rewrite::Error),
#[error("must provide only one InfluxQl statement per query")]
InfluxqlSingleStatement,
#[error("must specify a 'db' parameter, or provide the database in the InfluxQL query")]
InfluxqlNoDatabase,
#[error(
"provided a database in both the parameters ({param_db}) and \
query string ({query_db}) that do not match, if providing a query \
that specifies the database, you can omit the 'database' parameter \
from your request"
)]
InfluxqlDatabaseMismatch { param_db: String, query_db: String },
#[error(
"provided a retention policy in both the parameters ({param_rp}) and \
query string ({query_rp}) that do not match, if providing a query \
that specifies the retention_policy, you can omit the 'rp' parameter \
from your request"View on GitHub (pinned to 06200ef96b)