{"record":{"id":"85780c6c2258a4e8","repo":"cube-js/cube","slug":"second-argument-must-be-a-jsbox-arc-queryresult","errorCode":null,"errorMessage":"Second argument must be a JsBox<Arc<QueryResult>> or a JsBuffer with columnar JsRawColumnarData JSON","messagePattern":"Second argument must be a JsBox<Arc<QueryResult>> or a JsBuffer with columnar JsRawColumnarData JSON","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-native/src/orchestrator.rs","lineNumber":234,"sourceCode":"        Err(err) => cx.throw_error(err.to_string()),\n    }\n}\n\nfn extract_query_result(\n    cx: &mut FunctionContext<'_>,\n    data_arg: Handle<JsValue>,\n) -> Result<Arc<QueryResult>, anyhow::Error> {\n    if let Ok(js_box) = data_arg.downcast::<JsBox<Arc<QueryResult>>, _>(cx) {\n        Ok(Arc::clone(&js_box))\n    } else if let Ok(js_buffer) = data_arg.downcast::<JsBuffer, _>(cx) {\n        let bytes = js_buffer.as_slice(cx);\n        let js_raw_data: JsRawColumnarData = serde_json::from_slice(bytes)?;\n\n        QueryResult::from_js_raw_data(js_raw_data)\n            .map(Arc::new)\n            .map_err(anyhow::Error::from)\n    } else {\n        Err(anyhow::anyhow!(\n            \"Second argument must be a JsBox<Arc<QueryResult>> or a JsBuffer with columnar JsRawColumnarData JSON\"\n        ))\n    }\n}\n\npub fn parse_cubestore_result_message(mut cx: FunctionContext) -> JsResult<JsPromise> {\n    let msg = cx.argument::<JsBuffer>(0)?;\n    let msg_data = msg.as_slice(&cx).to_vec();\n\n    let promise = cx\n        .task(move || QueryResult::from_cubestore_fb(&msg_data))\n        .promise(move |mut cx, res| match res {\n            Ok(result) => Ok(cx.boxed(Arc::new(result))),\n            Err(err) => cx.throw_error(err.to_string()),\n        });\n\n    Ok(promise)\n}","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-native/src/orchestrator.rs#L216-L252","documentation":"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.","triggerScenarios":"Thrown at packages/cubejs-backend-native/src/orchestrator.rs:234 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}