Repository navigation
fix(python-sdk): keep raw mo_ctl output when the reply is not JSON - #31524
Conversation
A non-JSON mo_ctl reply raised MoCtlError with only the JSON decoder message, so callers could not see what the server actually returned. MoCtlErrors raised inside the try block (no rows, failed returnStr) were also re-wrapped by the generic handler, producing "mo_ctl operation failed: mo_ctl operation failed: ...". Decode through one shared helper that puts a raw-output preview in the message and the full text on error.raw_output, and let MoCtlError pass through unwrapped, in both the sync and async managers. Refs matrixorigin#31384
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: ac62eb154ee28e4b7e72c46a6cb39a754ba9dfc1
Assessment: approve
The complete delta preserves non-JSON output with a bounded preview, retains existing exception classes, and prevents double wrapping. This matches the linked issue’s follow-up decision. No actionable defects or unresolved discussion concerns remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
28 focused repository tests passed; moctl-tests.log matches checks/1793165593676580840-3.json.
-
27 diagnostic cases passed, covering preview bounds, raw-output retention, public methods, error identity, causes and cancellation; moctl-probe.log matches checks/1793165681024883415-3.json.
-
Frozen-base controls reproduced lost raw text and double wrapping while preserving successful JSON results; base-control.log matches checks/1793165680878279851-3.json.
-
git diff --check passed. Verified clean frozen source and reconciled receipts, logs and discussion coverage. Records are in /home/xupeng/.local/state/mo-bot/jobs/a8547b11a6f32bff24c84777/attempt-1/discussion-assessment.json and validation-manifest.json; audit receipt: checks/1793165806807820876-4.json.
Limitations:
- Executed with Python 3.13.5 and SQLAlchemy 2.1.6 using mocked transport. No live-server run, full offline suite or multi-version matrix was performed; native result production was source-traced.
✅ Merged into
|
| Condition | Required by | |
|---|---|---|
| ✅ | #review-threads-unresolved = 0 |
GitHub branch protection |
| ✅ | github-review-approved |
GitHub branch protection |
The batch, tested in place
| Condition | Required by | |
|---|---|---|
| ✅ | any of: check-success = CI Required, check-neutral = CI Required, check-skipped = CI Required |
GitHub branch protection |
Times in UTC · dashboard · how the merge queue works
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #31384
What this PR does / why we need it:
The escaping parts of #31384 are already fixed on
main(#31262 formetadata_scanand #31322 for_build_moctl_sql; see the issue comment). This PR fixes what is left: expected behavior #2, a non-JSONmo_ctlreply.Root cause.
_execute_moctl(sync inmoctl.py, async inasync_client.py) calledjson.loads(result_str)directly. On a plain-text reply it raisedMoCtlError("Failed to parse mo_ctl result: Expecting value: line 1 column 1 (char 0)"), and the server's actual output was lost.MoCtlErrorraised inside thetryblock (no rows, or areturnStrother thanOK) was caught again byexcept Exceptionand re-wrapped, so the message readmo_ctl operation failed: mo_ctl operation failed: table not found. In the async manager the same re-wrap also hid the JSON error behind the generic prefix.Fix.
_decode_moctl_result()inmoctl.py, shared by both managers. On non-JSON it raises the manager's ownMoCtlErrorclass: the sync manager usesmatrixone.moctl.MoCtlErrorand the async manager usesmatrixone.exceptions.MoCtlError, as before.error.raw_output.except MoCtlError: raiselets SDK errors pass through unwrapped. Other exceptions are still wrapped as before.Tests (
tests/offline/test_moctl.py):test_execute_moctl_non_json_keeps_raw_output: a sync plain-text reply keeps the raw text in the message and inraw_output.test_async_execute_moctl_non_json_keeps_raw_output: the same check for the async manager.test_execute_moctl_failed_return_str_is_not_double_wrapped: the message is exactlymo_ctl operation failed: table not found.Results:
mo_ctl operation failed: mo_ctl operation failed: table not found). After the fix, all 3 pass.test_moctl.py+test_moctl_simple.py: 26 passed.pytest tests/offline(Python 3.13, run locally): 2289 passed, 95 subtests passed.black --checkis clean.flake8reports no new warnings (4 before, 4 after; all are existing unused imports inasync_client.py).3 files, +61/-9.
本操作由 LW 授权的 Grok Bot 智能体执行