{"record":{"id":"5a46a6d897457d30","repo":"influxdata/influxdb","slug":"python-function-call-failed","errorCode":null,"errorMessage":"Python function call failed: {}","messagePattern":"Python function call failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"influxdb3_py_api/src/system_py.rs","lineNumber":601,"sourceCode":"\n        let query_params = map_to_py_object(py, &query_params).map_err(anyhow::Error::from)?;\n        let request_params = map_to_py_object(py, &request_headers).map_err(anyhow::Error::from)?;\n\n        let py_func = load_plugin_function(\n            py,\n            code,\n            plugin_root,\n            PROCESS_REQUEST_CALL_SITE,\n            ExecutePluginError::MissingProcessRequestFunction,\n        )?;\n\n        // convert the body bytes into python bytes blob\n        let request_body = PyBytes::new(py, &request_body[..]);\n\n        // get the result from calling the python function\n        let result = py_func\n            .call1((local_api, query_params, request_params, request_body, args))\n            .map_err(|e| anyhow!(\"Python function call failed: {}\", e))?;\n\n        // Process the result according to Flask conventions\n        process_flask_response(py, result)\n    })?;\n\n    logger.log(\n        LogLevel::Info,\n        format!(\n            \"finished execution in {}\",\n            format_duration(start_time.elapsed())\n        ),\n    );\n\n    let plugin_state = PluginReturnState {\n        log_lines: logger.take_log_lines(),\n        write_db_lines: write_accumulator.flush(),\n    };\n","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/influxdata/influxdb/blob/d28e26e048401c53cbb98cf2d6ab0cf1e98048ca/influxdb3_py_api/src/system_py.rs#L583-L619","documentation":"The Rust host resolved the plugin's entry-point function and invoked it with call1((api, query_params, request_params, body, args)). This error wraps any exception the Python function raised (or a failure binding the five arguments); the {} placeholder is the full Python traceback. It is the generic 'your plugin code raised' error for request-processing plugins.","triggerScenarios":"Any uncaught exception inside process_request: KeyError/IndexError on query_params, request_params, or args; TypeError from a signature that does not accept the five arguments; errors raised by the influxdb3 system API object; or third-party library failures inside the handler.","commonSituations":"Plugin written against a different SDK signature after a server upgrade; accessing a header/param that a specific route never sends; unhandled database or network errors inside the plugin.","solutions":["Read the embedded traceback - it pinpoints the plugin file and line that raised","Invoke the function standalone with the same five-argument signature (api, query_params, request_params, body, args) to reproduce","Use .get() and type checks on all params/dicts instead of direct indexing","Wrap the handler body in try/except and return a 500 Flask-style tuple so one bad request cannot break the plugin"],"exampleFix":"# before\ndef process_request(api, query_params, request_params, body, args):\n    return {'q': query_params['required_key']}  # KeyError -> Python function call failed\n\n# after\ndef process_request(api, query_params, request_params, body, args):\n    try:\n        return {'q': query_params['required_key']}\n    except Exception:\n        return ({'error': 'bad request', 'detail': traceback.format_exc()}, 500)\n","handlingStrategy":"try-catch","validationCode":"# verify the signature matches what the host calls\nimport inspect\nsig = inspect.signature(process_request)\nnames = list(sig.parameters)\nassert len(names) == 5, f'expected 5 args, got {names}'\n","typeGuard":null,"tryCatchPattern":"def process_request(api, query_params, request_params, body, args):\n    try:\n        ...  # handler body\n    except Exception:\n        api.logger.error(traceback.format_exc())\n        return ({'error': 'internal error'}, 500)  # keep the plugin alive\n","preventionTips":["Use .get() with defaults for every query_params/request_params/args access","Pin the plugin SDK version matching the influxdb3 server release","Smoke-test plugins with a minimal request before enabling them in production","Log to the plugin logger (influxdb logger) so failures are visible server-side"],"tags":["python-plugin","influxdb3","unhandled-exception","traceback"],"backgroundTag":"python-plugin-unhandled-exception","analyzedSha":"d28e26e048401c53cbb98cf2d6ab0cf1e98048ca","analyzedAt":"2026-08-16T19:53:34.623Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}