influxdata/influxdb · error

Python function call failed: {}

Error message

Python function call failed: {}

What it means

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.

Source

Thrown at influxdb3_py_api/src/system_py.rs:601

        let query_params = map_to_py_object(py, &query_params).map_err(anyhow::Error::from)?;
        let request_params = map_to_py_object(py, &request_headers).map_err(anyhow::Error::from)?;

        let py_func = load_plugin_function(
            py,
            code,
            plugin_root,
            PROCESS_REQUEST_CALL_SITE,
            ExecutePluginError::MissingProcessRequestFunction,
        )?;

        // convert the body bytes into python bytes blob
        let request_body = PyBytes::new(py, &request_body[..]);

        // get the result from calling the python function
        let result = py_func
            .call1((local_api, query_params, request_params, request_body, args))
            .map_err(|e| anyhow!("Python function call failed: {}", e))?;

        // Process the result according to Flask conventions
        process_flask_response(py, result)
    })?;

    logger.log(
        LogLevel::Info,
        format!(
            "finished execution in {}",
            format_duration(start_time.elapsed())
        ),
    );

    let plugin_state = PluginReturnState {
        log_lines: logger.take_log_lines(),
        write_db_lines: write_accumulator.flush(),
    };

View on GitHub (pinned to d28e26e048)

Solutions

  1. Read the embedded traceback - it pinpoints the plugin file and line that raised
  2. Invoke the function standalone with the same five-argument signature (api, query_params, request_params, body, args) to reproduce
  3. Use .get() and type checks on all params/dicts instead of direct indexing
  4. Wrap the handler body in try/except and return a 500 Flask-style tuple so one bad request cannot break the plugin

Example fix

# before
def process_request(api, query_params, request_params, body, args):
    return {'q': query_params['required_key']}  # KeyError -> Python function call failed

# after
def process_request(api, query_params, request_params, body, args):
    try:
        return {'q': query_params['required_key']}
    except Exception:
        return ({'error': 'bad request', 'detail': traceback.format_exc()}, 500)
Defensive patterns

Strategy: try-catch

Validate before calling

# verify the signature matches what the host calls
import inspect
sig = inspect.signature(process_request)
names = list(sig.parameters)
assert len(names) == 5, f'expected 5 args, got {names}'

Try / catch

def process_request(api, query_params, request_params, body, args):
    try:
        ...  # handler body
    except Exception:
        api.logger.error(traceback.format_exc())
        return ({'error': 'internal error'}, 500)  # keep the plugin alive

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of influxdata/influxdb@d28e26e048 (2026-08-16). Data as JSON: /api/errors/5a46a6d897457d30. Report an issue: GitHub.