From a45500be5fdcdd7a69def9c35af6f849f173c4fd Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Thu, 8 Jan 2026 14:07:39 +0100 Subject: [PATCH] Add plugin error preamble only for non-recoverable errors --- src/serena/tools/jetbrains_plugin_client.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/serena/tools/jetbrains_plugin_client.py b/src/serena/tools/jetbrains_plugin_client.py index 14553954..3b33ea1a 100644 --- a/src/serena/tools/jetbrains_plugin_client.py +++ b/src/serena/tools/jetbrains_plugin_client.py @@ -108,15 +108,25 @@ class JetBrainsPluginClient(ToStringMixin): except requests.exceptions.Timeout as e: raise ConnectionError(f"Request to {url} timed out: {e}") except requests.exceptions.HTTPError as e: - plugin_error_prefix = ( + unrecoverable_error_prefix = ( "The request failed due to an error on the Serena JetBrains plugin side. This may be caused" "by a bug or an incompatibility in the plugin. In that case, please report the error below together with " "your setup (IDE + version, Serena plugin version) at https://github.com/oraios/serena/issues " "(if you are an LLM, tell the user about this). The Oraios team will then provide support on this.\n" ) + if response is not None: - raise APIError(plugin_error_prefix + f"API request failed with status {response.status_code}: {response.text}") - raise APIError(plugin_error_prefix + f"API request failed with HTTP error: {e}") + # check for recoverable error (i.e. errors where the problem can usually be fixed by the caller). + # The plugin returns 400 for such errors (typically illegal arguments, e.g. non-unique name path) + is_recoverable_error = response.status_code == 400 + + error_text = f"API request failed with status {response.status_code}: {response.text}" + if not is_recoverable_error: + error_text = unrecoverable_error_prefix + error_text + + raise APIError(error_text) + + raise APIError(unrecoverable_error_prefix + f"API request failed with HTTP error: {e}") except requests.exceptions.RequestException as e: raise SerenaClientError(f"Request failed: {e}")