Skip to content

fix(python-sdk): map SHOW ACCOUNTS columns by the server layout - #31527

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix/31394-show-accounts-columns
Oct 28, 2026
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix/31394-show-accounts-columns

Conversation

@MatrixAdventurer

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #31394

What this PR does / why we need it:

Root cause. _row_to_account (in both BaseAccountManager and AsyncAccountManager) assumed this SHOW ACCOUNTS layout: name, admin, created, status, comment, suspended_time, suspended_reason.

The server's actual layout, from pkg/frontend/show_account.go (idxOfAccountName … idxOfComment, the same on main and 4.1-dev), is: account_name, admin_name, created_time, status, suspended_time, db_count, tbl_count, size, snapshot_size, comments.

As a result:

  • Account.comment received suspended_time.
  • suspended_time received db_count.
  • suspended_reason received tbl_count.
  • The real comments column was never read, so create_account(..., comment=...) and alter_account(comment=...) never round-tripped.

Fix.

  • One helper, _show_accounts_row_to_account, maps the columns by the server layout (suspended_time = col 4, comments = col 9). The sync and async managers both use it.
  • SHOW ACCOUNTS has no suspension-reason column. The SDK's SUSPEND COMMENT '<reason>' stores the reason as the account comment (see account_comment_opt in the grammar). So suspended_reason is now None, and the reason shows up in comment.

Tests (tests/offline/test_account.py):

  • New test_get_account_maps_show_accounts_columns_by_layout: given a real 10-column row, comment == 'quarterly audit', suspended_time is the timestamp, and suspended_reason is None.
  • Four existing tests used the wrong 7-column fixture and asserted the buggy mapping. They now use a show_accounts_row() helper that builds the real layout. The suspend test now asserts the reason appears as comment, together with suspended_time.

Results:

  • Before the fix, the new test and the 4 updated tests fail. For example, the new test gets AssertionError: datetime(2026, 10, 27, 8, 0) != 'quarterly audit', meaning the comment field received suspended_time. After the fix, they pass.
  • pytest tests/offline (Python 3.13, run locally): 2287 passed, 95 subtests passed.
  • flake8 reports no new findings.
  • black is clean on account.py. It reports only one existing over-long line in test_account.py, which this PR does not touch.

2 files, +55/-30.

本操作由 LW 授权的 Grok Bot 智能体执行

_row_to_account read SHOW ACCOUNTS as name, admin, created, status,
comment, suspended_time, suspended_reason. The server emits
account_name, admin_name, created_time, status, suspended_time,
db_count, tbl_count, size, snapshot_size, comments, so Account.comment
got suspended_time, suspended_time got db_count, suspended_reason got
tbl_count, and the real comment was never read.

Map columns by the server layout in one helper shared by the sync and
async managers. SHOW ACCOUNTS has no suspension reason column (SUSPEND
COMMENT stores the reason as the comment), so suspended_reason is None.

Refs matrixorigin#31394
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/bug Something isn't working label Oct 28, 2026
@XuPeng-SH

XuPeng-SH commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: ae83b70730cbe1f280f74957e80aa50ac7a924e5

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: ae83b70730cbe1f280f74957e80aa50ac7a924e5

Assessment: approve

The shared mapper correctly restores comment and suspension metadata for sync and async callers. Server output and suspension-comment semantics support the changed expectations. Complete review found no actionable defects or substantive discussion concerns.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

Validation:

  • Recovered and verified attempt-1 receipts, commands, source fingerprints and logs; 39 account tests passed without skips.

  • Baseline/candidate probe reproduced the original defect and verified sync/async get/list, session executors, NULLs, short rows and trailing object_count.

  • Frozen CI reports seven successful Python/SQLAlchemy offline configurations and successful Python 3.8/3.9 core imports.

  • Source remained unchanged. Recovery audit, receipt-reconciliation.json and complete discussion-assessment.json are retained under /home/xupeng/.local/state/mo-bot/jobs/014ae5e10a8c043243d7e081/attempt-2.

Limitations:

  • No live-server round trip was run; online CI was skipped. Local probes used actual SDK managers with executor doubles.

  • Decoding remains positional. It matches the frozen server contract; arbitrary future column reordering and historical server layouts were not validated.

@mergify mergify Bot added the queued label Oct 28, 2026
@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as f7e89bc at 06:32 UTC

43 min in the queue, 2 min of it CI.

So far

  • ✅ Entered the queue Wed 28 Oct, 05:49 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 06:32 · f7e89bc · squash
Merge conditions: 3 of 3 met

This pull request

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

@mergify
mergify Bot requested a review from aptend as a code owner October 28, 2026 06:29
@mergify
mergify Bot merged commit f7e89bc into matrixorigin:main Oct 28, 2026
29 of 30 checks passed
@mergify mergify Bot removed the queued label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: _row_to_account maps SHOW ACCOUNTS columns positionally and reads the wrong fields

2 participants