{"record":{"id":"fdaf619e081143f6","repo":"influxdata/influxdb","slug":"python-function-call-failed-e","errorCode":null,"errorMessage":"Python function call failed: {e}","messagePattern":"Python function call failed: (.+?)","errorType":"error_code","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"influxdb3_py_api/src/system_py.rs","lineNumber":592,"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":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_py_api/src/system_py.rs#L574-L610","documentation":"This error wraps any Python exception raised while invoking the user's processing-request plugin function (loaded via load_plugin_function) during an HTTP request trigger execution in InfluxDB 3. The Rust host calls the Python function with (local_api, query_params, request_headers, request_body, args); if that call raises any Python-side exception (traceback included in the message), it is converted into this anyhow error. It is a pass-through wrapper: the real cause is the Python traceback inside `{e}`.","triggerScenarios":"The Python request-trigger function raises an exception at runtime: unhandled Python errors in plugin code (AttributeError, KeyError, etc.), the plugin calling api.query/write incorrectly (e.g. bad SQL passed to the query endpoint), exceptions raised by importable module loading at call time, or the plugin accessing api members in unsupported ways that raise Python exceptions.","commonSituations":"Plugin code has a bug (typo, missing import, bad index); the plugin queries a database/table that does not exist so the query call raises; the plugin writes invalid line protocol and the write endpoint errors as a Python exception; plugin expects a different argument signature than (api, query_params, request_headers, body, args); Python dependencies used by the plugin are missing in the execution environment.","solutions":["Read the Python traceback embedded after 'Python function call failed:' in the log and fix the raised exception in the plugin code","Verify the plugin function signature matches (api, query_params, request_headers, request_body, args)","Wrap risky plugin sections in try/except and return an error HTTP response instead of raising","Test the plugin's SQL queries and line protocol writes directly (influxdb3 query / write CLI) to confirm they are valid","Ensure any third-party Python packages the plugin imports are installed in the plugin environment"],"exampleFix":"// before (plugin)\ndef process_request(api, query_params, headers, body, args):\n    table = args['table']\n    result = api.query(f'SELECT * FROM {table}')\n// after (plugin)\ndef process_request(api, query_params, headers, body, args):\n    table = args.get('table')\n    if table is None:\n        return (400, {'error': 'missing table arg'}, {'Content-Type': 'application/json'})\n    result = api.query(f'SELECT * FROM \"{table}\"')","handlingStrategy":"try-catch","validationCode":"def _validate_args(args):\n    required = {'table'}\n    missing = required - set(args or {})\n    if missing:\n        raise ValueError(f'missing args: {missing}')","typeGuard":null,"tryCatchPattern":"def process_request(api, query_params, headers, body, args):\n    try:\n        # plugin logic that may raise\n        result = api.query('SELECT * FROM measurements')\n        return result\n    except Exception as e:\n        return (500, {'error': str(e)}, {'Content-Type': 'application/json'})","preventionTips":["Wrap plugin bodies in try/except and return error responses instead of raising","Test plugin SQL and line protocol against the real database before deploying","Keep the plugin function signature (api, query_params, request_headers, request_body, args)","Pre-install and pin all Python dependencies the plugin imports"],"tags":["python","plugin-execution","unhandled-exception","influxdb3"],"backgroundTag":"api-request-failed","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}