-
Notifications
You must be signed in to change notification settings - Fork 138
TEL-1026: Utility for extracting transfer error details from error- #999 #808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
genseric-ghiro
wants to merge
4
commits into
main
Choose a base branch
from
genseric/tel-912-transfer-error-details
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+76
−16
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
835e668
Expose the SIP transfer failure reason on SipCallError
genseric-ghiro 655f8ed
Merge remote-tracking branch 'origin/main' into genseric/tel-912-tran…
genseric-ghiro 0872272
Removing confusing comment
genseric-ghiro 8051f42
Linting
genseric-ghiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ | |
|
|
||
| import livekit.api as api | ||
| from livekit.api import SipCallError, ServerError | ||
| from livekit.api.sip_service import _as_sip_error | ||
| from livekit.protocol.rtc import SessionDescription | ||
|
|
||
| BASE = os.getenv("LK_TEST_SERVER_URL", "http://127.0.0.1:9999") | ||
|
|
@@ -564,6 +565,43 @@ def test_sip_no_answer(): | |
| assert err.sip_status_code == 408 | ||
|
|
||
|
|
||
| # -- transfer failures surface the reason ------------------------------------- | ||
|
|
||
|
|
||
| def _transfer_error(**metadata: str) -> ServerError: | ||
| return _as_sip_error( | ||
| ServerError("deadline_exceeded", "call transfer failed", status=408, metadata=metadata) | ||
| ) | ||
|
|
||
|
|
||
| def test_sip_transfer_reason(): | ||
| err = _transfer_error(sip_transfer_reason="STR_RINGING_TIMEOUT", sip_transfer_id="STR_abc") | ||
| assert isinstance(err, SipCallError) | ||
| assert err.sip_transfer_reason == "STR_RINGING_TIMEOUT" | ||
| assert err.sip_transfer_id == "STR_abc" | ||
| # No SIP response was involved in this failure. | ||
| assert err.sip_status_code is None | ||
| assert "STR_RINGING_TIMEOUT" in str(err) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curiously, should we also do In case "STR_abc" should be in the error str ? |
||
|
|
||
|
|
||
| def test_sip_transfer_rejected_reports_reason_and_status(): | ||
| err = _transfer_error( | ||
| sip_transfer_reason="STR_REJECTED", | ||
| sip_status_code="486", | ||
| sip_status="Busy Here", | ||
| ) | ||
| assert err.sip_transfer_reason == "STR_REJECTED" | ||
| assert err.sip_status_code == 486 | ||
| assert err.sip_status == "Busy Here" | ||
| assert "STR_REJECTED" in str(err) | ||
| assert "486" in str(err) and "Busy Here" in str(err) | ||
|
|
||
|
|
||
| def test_non_sip_error_is_unchanged(): | ||
| err = ServerError("unauthenticated", "bad token", status=401) | ||
| assert _as_sip_error(err) is err | ||
|
|
||
|
|
||
| # -- cross-cutting: client-side dial timeout ---------------------------------- | ||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curiously, is there any specific reason that we want to filter out sip_transfer_id from the logs here ?
Is it intentional ?