cube-js/cube · error
Second argument must be a JsBox<Arc<QueryResult>> or a JsBuf
Error message
Second argument must be a JsBox<Arc<QueryResult>> or a JsBuffer with columnar JsRawColumnarData JSON
What it means
extract_query_result accepts exactly two shapes for its argument — a JsBox holding an Arc<QueryResult> (from a prior native call) or a JsBuffer containing JsRawColumnarData columnar JSON (from the JS side). This error means the downcast to both failed: the JS value passed as the second argument is neither of those shapes.
Source
Thrown at packages/cubejs-backend-native/src/orchestrator.rs:234
Err(err) => cx.throw_error(err.to_string()),
}
}
fn extract_query_result(
cx: &mut FunctionContext<'_>,
data_arg: Handle<JsValue>,
) -> Result<Arc<QueryResult>, anyhow::Error> {
if let Ok(js_box) = data_arg.downcast::<JsBox<Arc<QueryResult>>, _>(cx) {
Ok(Arc::clone(&js_box))
} else if let Ok(js_buffer) = data_arg.downcast::<JsBuffer, _>(cx) {
let bytes = js_buffer.as_slice(cx);
let js_raw_data: JsRawColumnarData = serde_json::from_slice(bytes)?;
QueryResult::from_js_raw_data(js_raw_data)
.map(Arc::new)
.map_err(anyhow::Error::from)
} else {
Err(anyhow::anyhow!(
"Second argument must be a JsBox<Arc<QueryResult>> or a JsBuffer with columnar JsRawColumnarData JSON"
))
}
}
pub fn parse_cubestore_result_message(mut cx: FunctionContext) -> JsResult<JsPromise> {
let msg = cx.argument::<JsBuffer>(0)?;
let msg_data = msg.as_slice(&cx).to_vec();
let promise = cx
.task(move || QueryResult::from_cubestore_fb(&msg_data))
.promise(move |mut cx, res| match res {
Ok(result) => Ok(cx.boxed(Arc::new(result))),
Err(err) => cx.throw_error(err.to_string()),
});
Ok(promise)
}View on GitHub (pinned to 7d981676b3)
Solutions
- Pass the QueryResult object obtained from a previous native API call directly
- When sending raw columnar data, serialize JsRawColumnarData-conformant JSON into a Node Buffer and pass that buffer as the second argument
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at packages/cubejs-backend-native/src/orchestrator.rs:234 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/85780c6c2258a4e8.
Report an issue: GitHub.