Update surrealdb integration for 2.x#1899
Merged
Merged
Conversation
Deploying logfire-docs with
|
| Latest commit: |
2342005
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a597aac5.logfire-docs.pages.dev |
| Branch Preview URL: | https://update-surrealdb-2.logfire-docs.pages.dev |
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 2/5
- High-confidence compatibility bug in
logfire/_internal/integrations/surrealdb.py: checkingtypes.UnionTypeis not Python 3.9-safe and can raiseAttributeErrorat runtime. - This is a concrete user-facing regression risk for Python 3.9 environments, so the merge risk is elevated despite the issue being localized to one integration file.
- Pay close attention to
logfire/_internal/integrations/surrealdb.py- union-type detection needs a Python 3.9-safe approach to avoid runtime failures.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="logfire/_internal/integrations/surrealdb.py">
<violation number="1" location="logfire/_internal/integrations/surrealdb.py:30">
P1: This union-type check is not Python 3.9-safe: `types.UnionType` does not exist there and can raise `AttributeError` at runtime.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| if tp in (str, bool, int, float, type(None), uuid.UUID, Table, RecordIdType): | ||
| return False | ||
| if origin is Union: # pragma: no branch | ||
| if origin is Union or origin is types.UnionType: # pragma: no branch |
There was a problem hiding this comment.
P1: This union-type check is not Python 3.9-safe: types.UnionType does not exist there and can raise AttributeError at runtime.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At logfire/_internal/integrations/surrealdb.py, line 30:
<comment>This union-type check is not Python 3.9-safe: `types.UnionType` does not exist there and can raise `AttributeError` at runtime.</comment>
<file context>
@@ -26,7 +27,7 @@ def _is_complex_type(tp: type | type[Value]) -> bool:
if tp in (str, bool, int, float, type(None), uuid.UUID, Table, RecordIdType):
return False
- if origin is Union: # pragma: no branch
+ if origin is Union or origin is types.UnionType: # pragma: no branch
args = get_args(tp)
return any(_is_complex_type(arg) for arg in args)
</file context>
Suggested change
| if origin is Union or origin is types.UnionType: # pragma: no branch | |
| if origin is Union or (hasattr(types, 'UnionType') and origin is types.UnionType): # pragma: no branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
X | Y) unions in_is_complex_typeand to derive the message template from the baseSyncTemplatesignature, so all subclasses share the same span template regardless of subclass-specific overrides (e.g. WebSocket connections add an optionalsession_idparameter in 2.x).Why split out
This was originally part of #1898 (general dep update). It needs more scrutiny than a routine bump because the integration has to adapt to surrealdb 2.x's API surface, so it's been pinned
<2there and lives here on its own.Test plan
tests/otel_integrations/test_surrealdb.pypasses unchanged on both Python 3.12 and 3.14