databendlabs/databend · error
get_input_read_buffer_size should not fail
Error message
get_input_read_buffer_size should not fail
What it means
streaming_load_handler_inner reads the session setting `input_read_buffer_size` via get_input_read_buffer_size(), which returns Result because the setting value must parse as a number. The code expects it to always be valid since defaults are correct; an Err means the setting holds an unparseable/invalid value in the session, so the handler panics with 500.
Solutions
- Check the session/global value: `SELECT value FROM system.settings WHERE name='input_read_buffer_size'` and reset it with `SET input_read_buffer_size=<valid integer>`.
- Reset to default: `SET GLOBAL input_read_buffer_size = DEFAULT` (or restart session).
- Upgrade/patch so get_input_read_buffer_size maps errors to a 400 instead of expect().
- Validate any client-supplied settings at connection time.
Example fix
// before
let input_read_buffer_size = settings.get_input_read_buffer_size().expect("get_input_read_buffer_size should not fail") as usize;
// after
let input_read_buffer_size = settings.get_input_read_buffer_size()
.map_err(|e| HttpErrorCode::bad_request(format!("invalid input_read_buffer_size: {e}")))? as usize; Defensive patterns
Strategy: validation
Validate before calling
SELECT value FROM system.settings WHERE name = 'input_read_buffer_size'; -- must be a plain integer
Type guard
fn is_valid_buffer_size(v: &str) -> bool { v.parse::<u64>().is_ok() } Try / catch
let size = settings.get_input_read_buffer_size()
.map_err(|e| HttpErrorCode::bad_request(format!("invalid input_read_buffer_size: {e}")))?; Prevention
- Only set input_read_buffer_size to plain integers (no unit suffixes)
- Reset suspicious settings to DEFAULT
- Validate settings on SET to reject bad values early
- Map setting read errors to HTTP 4xx, never expect()
When it happens
Trigger: A session-level or global setting `input_read_buffer_size` was set to a non-numeric or invalid value (e.g. via SET or a connection settings string) before running the streaming load (POST /v1/streaming_load).
Common situations: Copy-pasted connection strings with wrong setting syntax; tenants overriding settings with formatted values like '128MB' where a plain integer is required; corrupted settings from older versions.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/940db88d90e3197d.
Report an issue: GitHub.
Appendix: source
Thrown at src/query/service/src/servers/http/v1/streaming_load.rs:236
let settings = query_context.get_settings();
let mut planner = Planner::new(query_context.clone());
let (mut plan, extras) = planner
.plan_sql(sql)
.await
.map_err(|err| err.display_with_sql(sql))
.map_err(BadRequest)?;
let entry = QueryEntry::create(&query_context, &plan, &extras).map_err(InternalServerError)?;
let _guard = QueriesQueueManager::instance()
.acquire(entry)
.await
.map_err(InternalServerError)?;
let input_read_buffer_size = settings
.get_input_read_buffer_size()
.expect("get_input_read_buffer_size should not fail")
as usize;
match &mut plan {
Plan::Insert(insert) => match &mut insert.source {
InsertInputSource::StreamingLoad(streaming_load) => {
if !streaming_load.file_format.support_streaming_load() {
return Err(poem::Error::from_string(
format!(
"Unsupported file format: {}",
streaming_load.file_format.get_type()
),
StatusCode::BAD_REQUEST,
));
}
let (tx, rx) = tokio::sync::mpsc::channel(1);
*streaming_load.receiver.lock() = Some(rx);
let format = streaming_load.file_format.clone();View on GitHub (pinned to 288d84d76e)