newrelic-python-agent icon indicating copy to clipboard operation
newrelic-python-agent copied to clipboard

GQL ariadne hook throws blocking error

Open jollysahil opened this issue 2 years ago • 1 comments

Description Ariadne GQL execute wrapper throws an unhandled error. The same GQL operation succeeds when newrelic is disabled.

Expected Behavior

  1. There shouldn't be an error thrown
  2. Errors in wrappers should be handled and not block critical operations

Troubleshooting or NR Diag results

Traceback (most recent call last):
 File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1820, in full_dispatch_request
 rv = self.dispatch_request()
 File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1796, in dispatch_request
 return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
 File "/usr/local/lib/python3.10/site-packages/newrelic/hooks/framework_flask.py", line 82, in _nr_wrapper_handler_
 return wrapped(*args, **kwargs)
 File "/usr/local/lib/python3.10/site-packages/flask_restful/__init__.py", line 467, in wrapper
 resp = resource(*args, **kwargs)
 File "/usr/local/lib/python3.10/site-packages/flask/views.py", line 107, in view
 return current_app.ensure_sync(self.dispatch_request)(**kwargs)
 File "/usr/local/lib/python3.10/site-packages/flask_restful/__init__.py", line 582, in dispatch_request
 resp = meth(*args, **kwargs)
 File "/app/alpha/blueprints/graphql/graphql.py", line 43, in post
 success, result = ariadne.graphql_sync(
 File "/usr/local/lib/python3.10/site-packages/newrelic/hooks/framework_ariadne.py", line 66, in wrap_graphql_sync
 return wrapped(*args, **kwargs)
 File "/usr/local/lib/python3.10/site-packages/ariadne/graphql.py", line 183, in graphql_sync
 result = execute_sync(
 File "/usr/local/lib/python3.10/site-packages/graphql/execution/execute.py", line 1082, in execute_sync
 result = execute(
 File "/usr/local/lib/python3.10/site-packages/graphql/execution/execute.py", line 1030, in execute
 result = exe_context.execute_operation(operation, root_value)
 File "/usr/local/lib/python3.10/site-packages/newrelic/hooks/framework_graphql.py", line 143, in wrap_execute_operation
 trace.deepest_path = ".".join(traverse_deepest_unique_path(fields, fragments)) or ""
 TypeError: sequence item 1: expected str instance, NoneType found

Steps to Reproduce Not all GQL operations are failing due to this, I cannot share our specific operations

Your Environment newrelic==8.8.0 ariadne==0.19 graphql-core==3.2.1 Flask==2.2.2

newrelic.config

files:
  "/etc/newrelic-infra.yml" :
    mode: "000644"
    owner: root
    group: root
    content: |
      license_key: <redacted>

commands:
# Create the agent’s yum repository
  "01-agent-repository":
    command: sudo curl -o /etc/yum.repos.d/newrelic-infra.repo https://download.newrelic.com/infrastructure_agent/linux/yum/amazonlinux/2/x86_64/newrelic-infra.repo
#
# Update your yum cache
  "02-update-yum-cache":
    command: yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'
#
# Run the installation script
  "03-run-installation-script":
    command: sudo yum install newrelic-infra -y

newrelic.ini

distributed_tracing.enabled = true
monitor_mode = true
log_level = info
ssl = true
high_security = false
transaction_tracer.enabled = true
transaction_tracer.transaction_threshold = apdex_f
transaction_tracer.record_sql = obfuscated
transaction_tracer.stack_trace_threshold = 0.5
transaction_tracer.explain_enabled = true
transaction_tracer.explain_threshold = 0.5
error_collector.enabled = true
browser_monitoring.auto_instrument = true
thread_profiler.enabled = true

Additional context [TIP]: # ( Add any other context about the problem here. For example, relevant community posts or support tickets. )

jollysahil avatar May 07 '23 17:05 jollysahil

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 12 '23 10:08 stale[bot]

https://new-relic.atlassian.net/browse/NR-386428

Hello--sorry about the delay on this. I have a branch that should hopefully fix this. If this is still an issue you are having, could you try to use this branch to make sure I did not miss anything?

deepest-unique-path-None

You can install it using pip install git+https://github.com/newrelic/newrelic-python-agent.git@deepest-unique-path-None

lrafeei avatar Aug 12 '25 19:08 lrafeei