Skip to content

Commit 35e5cc2

Browse files
committed
fix(graphql): handle nil value for locations in unified_trace
1 parent 024e2cd commit 35e5cc2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/datadog/tracing/contrib/graphql/unified_trace.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def add_query_error_events(span, errors)
268268
@type_key => parsed_error.type,
269269
@stacktrace_key => parsed_error.backtrace,
270270
@message_key => graphql_error['message'],
271-
@locations_key => serialize_error_locations(graphql_error['locations']),
271+
@locations_key => self.class.serialize_error_locations(graphql_error['locations']),
272272
@path_key => graphql_error['path'],
273273
)
274274
)
@@ -285,7 +285,11 @@ def add_query_error_events(span, errors)
285285
# ]
286286
# is serialized as:
287287
# ["3:10", "7:8"]
288-
def serialize_error_locations(locations)
288+
def self.serialize_error_locations(locations)
289+
# locations are only provided by the `graphql` library when the error can
290+
# be associated to a particular point in the query.
291+
return [] if locations.nil?
292+
289293
locations.map do |location|
290294
"#{location["line"]}:#{location["column"]}"
291295
end

0 commit comments

Comments
 (0)