Skip to content

refactor: show error message#233

Open
v-alexmoraru wants to merge 9 commits into
microsoft:mainfrom
v-alexmoraru:dev/v-alexmoraru/show-error-message
Open

refactor: show error message#233
v-alexmoraru wants to merge 9 commits into
microsoft:mainfrom
v-alexmoraru:dev/v-alexmoraru/show-error-message

Conversation

@v-alexmoraru
Copy link
Copy Markdown
Member

Shows Fabric API error message more explicitly.

@v-alexmoraru v-alexmoraru requested a review from a team as a code owner May 7, 2026 05:51
Copilot AI review requested due to automatic review settings May 7, 2026 06:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates FabricAPIError to better surface raw error bodies when the Fabric API response can’t be parsed as JSON, and avoids printing a “Request Id” line when the ID is missing.

Changes:

  • Wrap Fabric API error-body parsing in a try/except to fall back to the raw response text on JSONDecodeError.
  • Only append “Request Id” to the formatted message when a request id is present.

Comment thread src/fabric_cli/core/fab_exceptions.py
Comment thread src/fabric_cli/core/fab_exceptions.py
@v-alexmoraru v-alexmoraru changed the title Show error message fix: show error message May 7, 2026
Copilot AI review requested due to automatic review settings May 7, 2026 07:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

Comment thread src/fabric_cli/core/fab_exceptions.py Outdated
Comment thread tests/test_utils/test_fab_custom_exception.py Outdated
Comment thread tests/test_utils/test_fab_custom_exception.py Outdated
Comment thread tests/test_utils/test_fab_custom_exception.py Outdated
Comment thread tests/test_utils/test_fab_custom_exception.py Outdated
Comment thread tests/test_utils/test_fab_custom_exception.py Outdated
Copilot AI review requested due to automatic review settings May 7, 2026 07:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/fabric_cli/core/fab_exceptions.py Outdated
Comment thread tests/test_utils/test_fab_custom_exception.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 7, 2026 07:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/fabric_cli/core/fab_exceptions.py
Comment thread .changes/unreleased/optimization-20260507-101040.yaml
@v-alexmoraru v-alexmoraru changed the title fix: show error message refactor: show error message May 7, 2026
Comment thread src/fabric_cli/core/fab_exceptions.py
Copilot AI review requested due to automatic review settings May 15, 2026 05:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (3)

src/fabric_cli/utils/fab_ui.py:208

  • The new debug-dependent text error path is not covered by the existing fab_ui tests. Please add coverage that sets debug_enabled true/false for a FabricAPIError with moreDetails, so regressions in whether verbose details are displayed are caught.
            is_debug = fab_state_config.get_config(fab_constant.FAB_DEBUG_ENABLED) == "true"
            _print_error_format_text(error.formatted_message(verbose=is_debug), command)

src/fabric_cli/core/fab_exceptions.py:124

  • request_id is appended without HTML escaping even though the final string is rendered as prompt-toolkit HTML. A server-provided request ID containing markup characters can break rendering or inject formatting; escape it the same way the base message and details are escaped.
        if self.request_id:
            final_message += f"\n<grey>∟ Request Id: {self.request_id}</grey>"

src/fabric_cli/core/fab_exceptions.py:86

  • This parser still is not used for common Fabric API statuses that do_request handles earlier (401, 403, and 404), so those responses continue to show generic CLI errors instead of the explicit Fabric API message described by the PR. The client routing needs to be updated or the scope/tests clarified.
        try:
            response = json.loads(response_text)

return
case "text":
_print_error_format_text(error.formatted_message(), command)
is_debug = fab_state_config.get_config(fab_constant.FAB_DEBUG_ENABLED) == "true"


def test_fabric_api_error_none_input_falls_back_to_default_message():
error = FabricAPIError(None)
Comment on lines +15 to +21
def __init__(self, message=None, status_code=NOT_SET):
# message: values like (None, "") fall back to the default.
# status_code: default is applied only when omitted entirely;
# an explicit None is preserved (e.g. fallback paths that have no code).
message = message or DEFAULT_ERROR_MESSAGE
status_code = status_code or DEFAULT_ERROR_CODE
if status_code is NOT_SET:
status_code = DEFAULT_ERROR_CODE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants