Skip to content

Commit b7fe47f

Browse files
committed
update error extensions
1 parent 450121e commit b7fe47f

File tree

1 file changed

+5
-12
lines changed
  • ddtrace/contrib/internal/graphql

1 file changed

+5
-12
lines changed

ddtrace/contrib/internal/graphql/patch.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,30 +288,23 @@ def _get_source_str(obj):
288288

289289

290290
def _validate_error_extensions(error: GraphQLError, extensions: Optional[str], attributes: Dict) -> Tuple[Dict, Dict]:
291-
# Validate user-provided extensions
291+
"""Validate user-provided extensions
292+
All extensions values MUST be stringified, EXCEPT for numeric values and
293+
boolean values, which remain in their original type.
294+
"""
295+
292296
if not extensions:
293297
return {}, attributes
294298

295299
fields = [e.strip() for e in extensions.split(",")]
296300
error_extensions = {}
297301
for field in fields:
298302
if field in error.extensions:
299-
# validate extensions formatting
300-
# All extensions values MUST be stringified, EXCEPT for numeric values and
301-
# boolean values, which remain in their original type.
302303
if isinstance(error.extensions[field], (int, float, bool)):
303304
error_extensions[field] = error.extensions[field]
304305
else:
305-
# q: could this be `None`?
306306
error_extensions[field] = str(error.extensions[field])
307307

308-
# Additional validation for Apollo Server attributes
309-
if field == "stacktrace":
310-
attributes["type"] = error.extensions[field].split(":")[0]
311-
attributes["stacktrace"] = "\n".join(error.extensions[field])
312-
elif field == "code":
313-
attributes["code"] = error.extensions[field]
314-
315308
return error_extensions, attributes
316309

317310

0 commit comments

Comments
 (0)