Skip to content

fix(python): reject mapping rows in insert_values - #31635

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix-31612-reject-mapping-rows
Oct 29, 2026
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix-31612-reject-mapping-rows

Conversation

@MatrixAdventurer

@MatrixAdventurer MatrixAdventurer commented Oct 29, 2026 •

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 #31612

What this PR does / why we need it:

MatrixOneSQLBuilder.insert_values() accepted mapping rows, converted each mapping to a list of keys, and bound those column-name strings as row data. This silently corrupted INSERT parameters instead of rejecting input that violates the positional-row API.

Validate each yielded row and copy it immediately into temporary storage before mutating builder state. This rejects any collections.abc.Mapping row, keeps failures atomic, preserves outer generators, and supports generators that reuse a mutable row buffer.

Regression coverage verifies:

  • plain dict and a generic Mapping are rejected;
  • a failed call does not replace already queued INSERT values;
  • an outer generator remains usable;
  • a generator may mutate and yield the same row list repeatedly without alias corruption.

Verification

  • Red on current main: both mapping cases failed to raise and replaced pending values.
  • Review regression before follow-up fix: reusable row buffer produced the final row twice.
  • Focused SQL Builder tests: 70 passed.
  • Complete offline suite: 2,334 passed.
  • Black, Flake8, compileall, and git diff --check: passed.
  • Independent follow-up review: APPROVE, no blocking findings.

@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 kind/bug Something isn't working kind/test-ci labels Oct 29, 2026
@XuPeng-SH

XuPeng-SH commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 5d1d9837af9ff8de64d36dfea5ad6b026d1f2f33

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: 5d1d9837af9ff8de64d36dfea5ad6b026d1f2f33

Assessment: request_changes

Mapping rejection works, but eager materialization introduces silent data corruption for generators that reuse a row buffer.

Model: gpt-6-astra / xhigh

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

  • P2 clients/python/matrixone/sql_builder.py:155: An outer generator updates and yields the same mutable list for successive positional rows.
    Impact: list(values) retains aliases until iteration finishes, so the later copies contain the final row repeatedly. Validate and immediately copy each yielded row into temporary storage, then update builder state after validation succeeds. Add a reused-buffer regression case.
    Evidence: The exact merge-base produces [(1, 'first'), (2, 'second') through SQLite execution; the candidate produces [(2, 'second'), (2, 'second')]. Reproduction: generator-control.py and generator-control.log; receipt checks/1793237372945735227-4.json. The added generator test yields independent lists and misses this case.

Validation:

  • 123 focused tests passed.

  • Mapping/state-preservation and unaffected positional-input controls passed; baseline/candidate comparison confirmed the regression.

  • Black, Flake8 and diff whitespace checks passed. Receipts and logs reconciled in validation-summary.json; source unchanged.

Limitations:

  • The complete offline suite was not rerun; its reported 2,333 passes lack supplied raw logs.

Copy link
Copy Markdown
Contributor Author

Addressed the P2 review finding in follow-up commit 009fc225.

The implementation now validates and copies each yielded row immediately into temporary storage, then updates builder state only after the entire iterable succeeds. This preserves reusable mutable row buffers and keeps failure atomic.

Added a regression generator that mutates and yields the same list twice.

Verification:

  • Reproduction before fix: [(2, 'second'), (2, 'second')]
  • Focused SQL Builder tests: 70 passed
  • Complete offline suite: 2,334 passed
  • Black, Flake8, compileall, and git diff --check: passed
  • Independent follow-up review: APPROVE, no blocking findings

@XuPeng-SH

XuPeng-SH commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 009fc225bb2c4975303e2952415a4ac3b370117a

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: 009fc225bb2c4975303e2952415a4ac3b370117a

Assessment: approve

Mapping rejection preserves pending INSERT state, and immediate row copying resolves the previously reported reusable-buffer regression. No actionable findings remain.

Model: gpt-6-astra / xhigh

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

Validation:

  • Reused supplied exact-head CI results: seven offline matrix jobs and two core-import jobs succeeded.

  • Extracted-class SQLite probe passed mapping rejection, iterator-failure atomicity, reusable-buffer and consumer controls.

  • Discussion coverage, source cleanliness and whitespace checks passed. Logs and receipts reconciled in validation-summary.json.

Limitations:

  • Local pytest could not start because pytest is unavailable; no local pytest pass is claimed.

  • CI raw logs were not supplied. The local probe does not validate full SDK imports.

@mergify mergify Bot added the queued label Oct 29, 2026
@mergify
mergify Bot merged commit 95341b4 into matrixorigin:main Oct 29, 2026
29 of 30 checks passed
@mergify

mergify Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

✅ Merged into main as 95341b4 at 02:26 UTC

Less than a minute in the queue, with no time running CI.

So far

  • ✅ Entered the queue Thu 29 Oct, 02:26 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged 02:26 · 95341b4 · 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

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 kind/test-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SDK insert_values() binds dict keys as row data

2 participants