code-analysis-client 1.6.241__tar.gz → 1.6.243__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/PKG-INFO +8 -3
  2. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/README.md +7 -2
  3. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/client.py +2 -8
  4. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/queue_wait.py +52 -2
  5. code_analysis_client-1.6.243/code_analysis_client/version.txt +1 -0
  6. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client.egg-info/PKG-INFO +8 -3
  7. code_analysis_client-1.6.241/code_analysis_client/version.txt +0 -1
  8. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/__init__.py +0 -0
  9. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/check_chain.py +0 -0
  10. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/commands_proxy.py +0 -0
  11. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/config.py +0 -0
  12. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/exceptions.py +0 -0
  13. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/file_session.py +0 -0
  14. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/py.typed +0 -0
  15. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/responses.py +0 -0
  16. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/schema_disk_cache.py +0 -0
  17. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/server_api.py +0 -0
  18. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/server_schema.py +0 -0
  19. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/universal_file.py +0 -0
  20. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/validation.py +0 -0
  21. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/vectorizer_state.py +0 -0
  22. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client/worktree.py +0 -0
  23. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client.egg-info/SOURCES.txt +0 -0
  24. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client.egg-info/dependency_links.txt +0 -0
  25. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client.egg-info/requires.txt +0 -0
  26. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/code_analysis_client.egg-info/top_level.txt +0 -0
  27. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/pyproject.toml +0 -0
  28. {code_analysis_client-1.6.241 → code_analysis_client-1.6.243}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code-analysis-client
3
- Version: 1.6.241
3
+ Version: 1.6.243
4
4
  Summary: Async JSON-RPC client for the code-analysis MCP server (mcp-proxy-adapter JsonRpcClient)
5
5
  Author-email: Vasiliy Zdanovskiy <vasilyvz@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -80,8 +80,13 @@ Failures raise instead of returning an error envelope:
80
80
  and `.error` (always a structured error dict).
81
81
  * `JobTimeoutError` — only when a positive `timeout` elapses; the call detaches and
82
82
  the job keeps running server-side (`websocket.on_timeout` is `detach`).
83
- * `ClientValidationError` — the server refused the parameters (JSON-RPC `-32602`);
84
- `details` carries the server's `violation` payload.
83
+ * `ClientValidationError` — the server refused the parameters (JSON-RPC `-32602`),
84
+ answered at the top level or carried by the failed job of an in-process command
85
+ (same text `JSON-RPC error: <message> (code: -32602)`, `code` `VALIDATION_ERROR`);
86
+ `details` carries the server's error `data` (e.g. its `violation` payload). A
87
+ command the server refuses before starting it with its own error code (for
88
+ example `VALIDATION_ERROR` for an unknown `project_id`) raises it with that exact
89
+ `code` and the server's `data` as `details`.
85
90
  * `ValueError` — a negative `timeout` or a non-positive `poll_interval`, before
86
91
  anything is sent.
87
92
 
@@ -68,8 +68,13 @@ Failures raise instead of returning an error envelope:
68
68
  and `.error` (always a structured error dict).
69
69
  * `JobTimeoutError` — only when a positive `timeout` elapses; the call detaches and
70
70
  the job keeps running server-side (`websocket.on_timeout` is `detach`).
71
- * `ClientValidationError` — the server refused the parameters (JSON-RPC `-32602`);
72
- `details` carries the server's `violation` payload.
71
+ * `ClientValidationError` — the server refused the parameters (JSON-RPC `-32602`),
72
+ answered at the top level or carried by the failed job of an in-process command
73
+ (same text `JSON-RPC error: <message> (code: -32602)`, `code` `VALIDATION_ERROR`);
74
+ `details` carries the server's error `data` (e.g. its `violation` payload). A
75
+ command the server refuses before starting it with its own error code (for
76
+ example `VALIDATION_ERROR` for an unknown `project_id`) raises it with that exact
77
+ `code` and the server's `data` as `details`.
73
78
  * `ValueError` — a negative `timeout` or a non-positive `poll_interval`, before
74
79
  anything is sent.
75
80
 
@@ -37,6 +37,7 @@ from code_analysis_client.queue_wait import (
37
37
  QueuedJob,
38
38
  StatusHook,
39
39
  check_wait_arguments,
40
+ invalid_params_error,
40
41
  map_adapter_error,
41
42
  result_from_unified,
42
43
  )
@@ -71,14 +72,7 @@ def _remote_invalid_params_as_client_validation(
71
72
  if details.get("code") != -32602:
72
73
  return None
73
74
 
74
- payload = details.get("data")
75
- payload = payload if isinstance(payload, dict) else {}
76
- field = payload.get("field")
77
- return ClientValidationError(
78
- str(error),
79
- field=field if isinstance(field, str) else "command",
80
- details=payload,
81
- )
75
+ return invalid_params_error(str(error), details.get("data"))
82
76
 
83
77
 
84
78
  class CodeAnalysisAsyncClient:
@@ -30,6 +30,7 @@ from mcp_proxy_adapter.client.jsonrpc_client.exceptions import (
30
30
  )
31
31
 
32
32
  from code_analysis_client.exceptions import (
33
+ ClientValidationError,
33
34
  CommandFailedError,
34
35
  JobFailedError,
35
36
  JobTimeoutError,
@@ -86,6 +87,36 @@ def _extract_inner_command_error(status_data: Dict[str, Any]) -> Any:
86
87
  return None
87
88
 
88
89
 
90
+ def remote_error_text(message: Any, code: Any) -> str:
91
+ """Text of a server JSON-RPC error, identical to the adapter's ``ClientRemoteResponseError``.
92
+
93
+ ``"JSON-RPC error: <message> (code: <code>)"`` - used for an error carried by a failed job so
94
+ that it reads exactly like the same error answered at the top level.
95
+ """
96
+ return f"JSON-RPC error: {message} (code: {code})"
97
+
98
+
99
+ def invalid_params_error(
100
+ message: str, data: Any, *, code: Optional[str] = None
101
+ ) -> ClientValidationError:
102
+ """Build the :class:`ClientValidationError` for a server refusal of a command's parameters.
103
+
104
+ The single constructor for the top-level -32602 refusal (``client.py``), a -32602 carried by a
105
+ failed job (``job_failure``) and a refused command-session open with the server's own error
106
+ code (``map_adapter_error``), so ``code`` / ``field`` / ``details`` have one shape: ``details``
107
+ is the server's error ``data`` object, ``field`` its ``field`` entry (else ``"command"``),
108
+ ``code`` ``VALIDATION_ERROR`` unless the server named its own code.
109
+ """
110
+ payload = data if isinstance(data, dict) else {}
111
+ field = payload.get("field")
112
+ return ClientValidationError(
113
+ message,
114
+ field=field if isinstance(field, str) else "command",
115
+ details=payload,
116
+ code=code,
117
+ )
118
+
119
+
89
120
  def command_failed(
90
121
  command: Optional[str], job_id: Optional[str], inner: Dict[str, Any]
91
122
  ) -> CommandFailedError:
@@ -100,8 +131,12 @@ def job_failure(
100
131
  job_id: Optional[str],
101
132
  status_data: Optional[Dict[str, Any]],
102
133
  terminal_event: Optional[Dict[str, Any]] = None,
103
- ) -> JobFailedError:
104
- """Build the :class:`JobFailedError` for a job that ended failed / stopped / cancelled.
134
+ ) -> Union[JobFailedError, ClientValidationError]:
135
+ """Build the error for a job that ended failed / stopped / cancelled.
136
+
137
+ A job whose structured error carries JSON-RPC ``-32602`` (the server validates after
138
+ enqueueing) yields :class:`ClientValidationError` exactly like a top-level refusal; every other
139
+ failure yields :class:`JobFailedError`.
105
140
 
106
141
  ``error`` is always the structured error object: the failed command's own error when the
107
142
  status payload carries one, else the queue-level error (a bare string is wrapped as
@@ -119,6 +154,10 @@ def job_failure(
119
154
  error = terminal_event.get("error")
120
155
  if not isinstance(error, dict):
121
156
  error = {"message": str(error) if error else f"job {status}", "status": status}
157
+ if error.get("code") == -32602:
158
+ return invalid_params_error(
159
+ remote_error_text(error.get("message"), -32602), error.get("data")
160
+ )
122
161
  return JobFailedError(job_id, error, status=status)
123
162
 
124
163
 
@@ -167,6 +206,11 @@ def map_adapter_error(
167
206
  * ``CommandSessionFailedError`` with a terminal event -> ``JobFailedError`` (structured error)
168
207
  * ``CommandSessionFailedError`` for a refused open (numeric ``code``) -> ``ClientRemoteResponseError``
169
208
  so the caller's JSON-RPC handling (-32602, -32601) is the same as on the HTTP path
209
+ * ``CommandSessionFailedError`` for a refused open carrying the server's own string error
210
+ ``code`` (the adapter forwards ``exc.code`` of the refusing exception, e.g. ``VALIDATION_ERROR``
211
+ from a command's ``validate_params`` before enqueue) -> ``ClientValidationError`` with that
212
+ exact ``code``, the server message and ``details`` = the server's ``data`` (the documented
213
+ refusal shape of :class:`ClientValidationError`)
170
214
  """
171
215
  if isinstance(exc, CommandSessionTimeoutError):
172
216
  details = exc.details if isinstance(exc.details, dict) else {}
@@ -205,6 +249,12 @@ def map_adapter_error(
205
249
  "command": command,
206
250
  },
207
251
  )
252
+ if isinstance(code, str) and code.strip():
253
+ return invalid_params_error(
254
+ str(details.get("error") or exc),
255
+ details.get("data"),
256
+ code=code.strip(),
257
+ )
208
258
  return None
209
259
 
210
260
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code-analysis-client
3
- Version: 1.6.241
3
+ Version: 1.6.243
4
4
  Summary: Async JSON-RPC client for the code-analysis MCP server (mcp-proxy-adapter JsonRpcClient)
5
5
  Author-email: Vasiliy Zdanovskiy <vasilyvz@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -80,8 +80,13 @@ Failures raise instead of returning an error envelope:
80
80
  and `.error` (always a structured error dict).
81
81
  * `JobTimeoutError` — only when a positive `timeout` elapses; the call detaches and
82
82
  the job keeps running server-side (`websocket.on_timeout` is `detach`).
83
- * `ClientValidationError` — the server refused the parameters (JSON-RPC `-32602`);
84
- `details` carries the server's `violation` payload.
83
+ * `ClientValidationError` — the server refused the parameters (JSON-RPC `-32602`),
84
+ answered at the top level or carried by the failed job of an in-process command
85
+ (same text `JSON-RPC error: <message> (code: -32602)`, `code` `VALIDATION_ERROR`);
86
+ `details` carries the server's error `data` (e.g. its `violation` payload). A
87
+ command the server refuses before starting it with its own error code (for
88
+ example `VALIDATION_ERROR` for an unknown `project_id`) raises it with that exact
89
+ `code` and the server's `data` as `details`.
85
90
  * `ValueError` — a negative `timeout` or a non-positive `poll_interval`, before
86
91
  anything is sent.
87
92