t8y2/dbx · error
{key} is required
Error message
{key} is required What it means
Validation error from `required_string`, a helper that extracts a mandatory string parameter from the JSON `params` object passed to `dispatch`/`dispatch_driver`. It fails when the key is absent, not a string (e.g. a number or null), or present but empty/whitespace-only. The message names the missing key so callers know which field to supply.
Source
Thrown at agents/drivers/tdengine/src/runtime.rs:381
_ => bail!("unknown method: {method}"),
}
}
fn decode<T: DeserializeOwned>(params: &Value) -> Result<T> {
serde_json::from_value(params.clone()).with_context(|| "invalid TDengine agent request parameters")
}
fn serialize<T: serde::Serialize>(value: T) -> Result<Value> {
serde_json::to_value(value).map_err(anyhow::Error::from)
}
fn required_string(params: &Value, key: &str) -> Result<String> {
params
.get(key)
.and_then(Value::as_str)
.map(str::to_string)
.filter(|value| !value.trim().is_empty())
.ok_or_else(|| anyhow!("{key} is required"))
}
fn optional_string(params: &Value, key: &str) -> String {
params.get(key).and_then(Value::as_str).unwrap_or_default().to_string()
}
fn optional_usize(params: &Value, key: &str) -> Option<usize> {
params.get(key).and_then(Value::as_u64).and_then(|value| usize::try_from(value).ok())
}
fn optional_u64(params: &Value, key: &str) -> Option<u64> {
params.get(key).and_then(Value::as_u64)
}
fn string_array(params: &Value, key: &str) -> Result<Vec<String>> {
params
.get(key)
.cloned()View on GitHub (pinned to c0390bff16)
Solutions
- Add the named key to the params JSON object as a non-empty string.
- Check the key spelling against the driver's expected parameter names.
- Ensure the value's JSON type is a string, not a number, boolean, or null.
- Trim-or-default client-side inputs so empty user input is caught before dispatch.
Example fix
// before
let params = json!({"action": "query"});
// after
let params = json!({"action": "query", "sql": "SELECT 1"}); // required key supplied Defensive patterns
Strategy: validation
Validate before calling
fn require_param(params: &serde_json::Value, key: &str) -> Result<&str, String> {
params.get(key)
.and_then(serde_json::Value::as_str)
.map(|s| s.trim())
.filter(|s| !s.is_empty())
.ok_or_else(|| format!("{key} is required"))
}
// call before dispatch: require_param(¶ms, "sql")?; Type guard
fn is_nonempty_str(v: &serde_json::Value) -> Option<&str> {
v.as_str().filter(|s| !s.trim().is_empty())
} Prevention
- Build params with a typed struct and serde so required fields are compile-time enforced.
- Validate all required keys at the call boundary before dispatch.
- Never serialize Option fields as null for required params; omit or supply real values.
- Add a unit test per dispatch action asserting each required key is present.
When it happens
Trigger: Calling dispatch/dispatch_driver without a required key in `params`; passing a JSON null, number, or object where a string is expected; passing `""` or `" "` which the `.filter(|v| !v.trim().is_empty())` rejects.
Common situations: Omitting fields like `id` or `sql` in hand-built JSON payloads; forgetting that whitespace-only values are rejected; sending the field with the wrong JSON type (unquoted or numeric); serializing optional fields as null.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- offsets must be an array
- Update pipeline must be an array
- Each update pipeline stage must be an object
- table is required
- lease, ttl, and preserveLease cannot be specified together
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/65e74174d00b3609.
Report an issue: GitHub.