refactor: show error message#233
Open
v-alexmoraru wants to merge 9 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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/exceptto fall back to the raw response text onJSONDecodeError. - Only append “Request Id” to the formatted message when a request id is present.
aviatco
reviewed
May 11, 2026
Contributor
There was a problem hiding this comment.
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_enabledtrue/false for aFabricAPIErrorwithmoreDetails, 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_idis 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_requesthandles 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 |
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.
Shows Fabric API error message more explicitly.