From d67752421e9c8752362089611f0ba4de897b883c Mon Sep 17 00:00:00 2001 From: Hannah Stepanek Date: Wed, 21 Aug 2024 22:50:28 -0700 Subject: [PATCH] Fixup: use hardened bind --- newrelic/hooks/mlmodel_langchain.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/newrelic/hooks/mlmodel_langchain.py b/newrelic/hooks/mlmodel_langchain.py index 11de2817f..9b7c7ffa5 100644 --- a/newrelic/hooks/mlmodel_langchain.py +++ b/newrelic/hooks/mlmodel_langchain.py @@ -125,12 +125,17 @@ } +def bind_submit(func, *args, **kwargs): + return {"func": func, "args": args, "kwargs": kwargs} + + def wrap_ContextThreadPoolExecutor_submit(wrapped, instance, args, kwargs): trace = current_trace() if not trace: return wrapped(*args, **kwargs) - bound_args = bind_args(wrapped, args, kwargs) + # Use hardened function signature bind so we have safety net catchall of args and kwargs. + bound_args = bind_submit(*args, **kwargs) bound_args["func"] = context_wrapper(bound_args["func"], trace=trace, strict=True) return wrapped(bound_args["func"], *bound_args["args"], **bound_args["kwargs"])