From 5dcddc5f9820a625462bf2a509e0244c533b1f8e Mon Sep 17 00:00:00 2001 From: riddle xu Date: Sun, 7 Apr 2024 18:35:39 +0800 Subject: [PATCH] [Internal] Init FlowRequestException with _inner_exception. (#2667) # Description In this PR, we init FlowRequestException with _inner_exception by param error. And then, we can use e.inner_exception for error handling. ![image](https://github.com/microsoft/promptflow/assets/2418764/b60b19e5-6950-4136-afa7-4f709cfa7119) # All Promptflow Contribution checklist: - [ ] **The pull request does not introduce [breaking changes].** - [ ] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).** - [ ] **Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: [suggested workflow](../CONTRIBUTING.md#suggested-workflow).** ## General Guidelines and Best Practices - [ ] Title of the pull request is clear and informative. - [ ] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [ ] Pull request includes test coverage for the included changes. --------- Co-authored-by: Yangtong Xu --- .../promptflow/azure/_restclient/flow_service_caller.py | 3 ++- .../tests/sdk_cli_azure_test/e2etests/test_run_operations.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/promptflow-azure/promptflow/azure/_restclient/flow_service_caller.py b/src/promptflow-azure/promptflow/azure/_restclient/flow_service_caller.py index c95c4c38146..7c29b3a7cd8 100644 --- a/src/promptflow-azure/promptflow/azure/_restclient/flow_service_caller.py +++ b/src/promptflow-azure/promptflow/azure/_restclient/flow_service_caller.py @@ -67,7 +67,8 @@ def wrapper(self, *args, **kwargs): f"Status code: {e.status_code} \n" f"Reason: {e.reason} \n" f"Error message: {e.message} \n", - privacy_info=[e.reason, e.message] + privacy_info=[e.reason, e.message], + error=e, ) return wrapper diff --git a/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_run_operations.py b/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_run_operations.py index 1c83b941083..027acbf7af8 100644 --- a/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_run_operations.py +++ b/src/promptflow/tests/sdk_cli_azure_test/e2etests/test_run_operations.py @@ -903,6 +903,11 @@ def check_inner_call(*args, **kwargs): # request id should be included in FlowRequestException assert f"request id: {pf.runs._service_caller._request_id}" in str(e.value) + inner_exception = e.value.inner_exception + assert inner_exception is not None + assert isinstance(inner_exception, HttpResponseError) + assert inner_exception.message == "customized error message." + # it is a known issue that executor/runtime might write duplicate storage for line records, # this will lead to the lines that assert line count (`len(detail)`) fails. @pytest.mark.xfail(reason="BUG 2819328: Duplicate line in flow artifacts jsonl", run=True, strict=False)