From a3de03b5564d3b10aeb55aa3b50b6ae9f45b814d Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Mon, 13 Jul 2026 22:30:55 +0200 Subject: [PATCH] Fix: jet_brains_run_inspections returned incorrectly transformed data The tool incorrectly applied the pythonification, even though it returns data not only in values but also in keys --- CHANGELOG.md | 1 + .../jetbrains/jetbrains_plugin_client.py | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e22ce18..a7fd62a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,7 @@ Status of the `main` branch. Changes prior to the next official version change w - Add configuration option `jetbrains_launch_command`, allowing Serena to spawn IDE instances automatically upon project activation - Fix: `jet_brains_list_inspections` failed when only default parameters were used #1615 + - Fix: `jet_brains_run_inspections` returned incorrectly transformed data (malforming snake-case conversion applied to all keys) * Dashboard: - Make list of trusted hosts configurable, fixing host validation introduced in v1.5.2 allowing only diff --git a/src/serena/jetbrains/jetbrains_plugin_client.py b/src/serena/jetbrains/jetbrains_plugin_client.py index 22fa9c27..090adbdf 100644 --- a/src/serena/jetbrains/jetbrains_plugin_client.py +++ b/src/serena/jetbrains/jetbrains_plugin_client.py @@ -303,7 +303,15 @@ class JetBrainsPluginClient(ToStringMixin): f"{self._plugin_version}. Ask the user to update the plugin!" ) - def _make_request(self, method: str, endpoint: str, data: Optional[dict] = None) -> dict[str, Any]: + def _make_request(self, method: str, endpoint: str, data: Optional[dict] = None, pythonify: bool = True) -> dict[str, Any]: + """ + :param method: the HTTP method to use ("GET" or "POST") + :param endpoint: the endpoint to call (e.g., "/findSymbol") + :param data: the data to send in the request body (for POST requests) + :param pythonify: whether to recursively "pythonify" the response object, converting all keys to snake_case. + This must not be enabled if *any* key contains variable data rather (and therefore isn't a well-defined DTO structure). + :return: the response as a dictionary + """ url = f"{self._base_url}{endpoint}" response: Response | None = None @@ -320,7 +328,11 @@ class JetBrainsPluginClient(ToStringMixin): # Try to parse JSON response try: - return self._pythonify_response(response.json()) + response_json = response.json() + if pythonify: + return self._pythonify_response(response_json) + else: + return response_json except json.JSONDecodeError: # If response is not JSON, return raw text return {"response": response.text} @@ -695,7 +707,7 @@ class JetBrainsPluginClient(ToStringMixin): request_data["startLine"] = start_line if end_line is not None: request_data["endLine"] = end_line - return cast(jb.RunInspectionsResponse, self._make_request("POST", "/runInspectionsOnFile", request_data)) + return cast(jb.RunInspectionsResponse, self._make_request("POST", "/runInspectionsOnFile", request_data, pythonify=False)) def list_inspections( self,