Skip to content

fix: classify invalid vector Base64 input as user error - #29363

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/29327-vector-base64-error
Sep 24, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/29327-vector-base64-error

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

Fixes #29327.

What this PR does / why we need it:

All six public VEC*_FROM_BASE64 functions share VecFromBase64[T]. Malformed Base64 and decoded byte lengths that do not fit the selected element width were incorrectly reported as MatrixOne internal errors. Those two user-input rejection paths now return ErrInvalidInput. Valid decoding and the internal guard for unsupported generic element types are unchanged.

Validation

  • On base 271c3f159957eab683cf4eb8474b7a353cfea622, the new focused test failed for all six malformed-input variants with internal error.
  • Focused TestVecFromBase64* and the full ./pkg/sql/plan/function package passed through mo-cgo-test with matching native artifacts, -count=1.
  • go vet -mod=readonly ./pkg/sql/plan/function passed. Incremental golangci-lint 2.5.0, built with Go 1.26.4, passed with 0 issues.
  • New vector_base64_invalid_input.sql passed normal mo-tester comparison twice against the task-owned standalone service: 11/11 statements per run, zero failed/ignored/abnormal. It checks all six malformed inputs, four applicable width mismatches, and a successful one-byte UINT8 control after errors.
  • gofmt and git diff --check passed. Independent GPT-6 medium design and whole-diff review found no blockers.

Risk and rollback

The public error classification and displayed prefix change from internal error to invalid input. This repository maps both to MySQL ER_UNKNOWN_ERROR; the MatrixOne error class is the intended contract. The CPU IVF-Flat caller produces well-formed, aligned Base64 and does not enter the changed branches. No GPU algorithm, native, protocol, or data-success path changes. Revert this commit to restore the previous classification.

Rebase and CI interpretation

Rebased onto main containing #29370, which fixes the unauthorized Quay MinIO image pulls used by Compose BVT. On the previous head, ordinary Ubuntu UT, SCA, and shared build passed; Compose BVT failed at image startup before executing the Base64 SQL. Coverage UT had a separate TestAutoIDCacheRestartAndDisabledNode context deadline failure in pkg/tests/issues/isolated. It must not be attributed to MinIO or to the changed Base64 error branches without a matching baseline. On the rebased head, focused TestVecFromBase64* and the full function package passed locally. CI for the rebased head should be read from its checks.

No distributed topology or GPU execution was run locally; the changed error branches do not depend on either.

@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 →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed current head d6bdf0f. No blocking findings. Malformed Base64 and decoded byte lengths that cannot form whole elements are now classified as invalid user input across all six vector element types; valid one-byte uint8 decoding remains the control. The unit tests check both error code and alignment message, and the distributed SQL fixture verifies the public error result and that a later valid call succeeds. Current-head CI is green. This self-authored COMMENT is not an approval.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Deep review of d6bdf0f290527a439b03a9eb25497a69ae0e9905 against base/merge-base 44e5226a21d7905a1d1e528d257321d2696c807b: PASS — no blocking findings; technically ready to merge.

Reviewed all four changed files for root-cause coverage, unhappy paths, test quality, duplication, and unnecessary complexity.

  • Fix completeness: all six public vector Base64 decoders resolve to VecFromBase64[T]. Both malformed Base64 and decoded-width mismatch now produce ErrInvalidInput. The unsupported generic-type guard remains an internal error. Valid decoding, NULL handling, and the IVF-Flat producer's correctly aligned payloads retain their behavior.
  • Public compatibility: the MatrixOne error class and displayed prefix change as intended. Both classes map to the existing MySQL ER_UNKNOWN_ERROR/default SQLSTATE; this does not introduce a new wire error number.
  • Engineering quality: two error-constructor replacements fix the shared cause. No new production abstraction, fallback, configuration, or dependency is needed. The focused table covers six malformed-input variants and the four applicable width mismatches; one-byte integer elements correctly have no alignment-error case. Existing round-trip tests provide the positive controls. Calling DebugRun is justified here because the ordinary test helper only checks whether any error occurred.
  • BVT quality: the dedicated 11-statement case asserts the SQL-visible rejection contract and successful UINT8 decoding after errors. It creates no database, table, transaction, or global setting. Its coverage complements the exact error-code UT without adding an expensive fixture.

Unhappy-path audit of the changed rejection paths and test fixture:

Check Conclusion
Q1: ownership/cleanup Decode scratch is local Go memory. Failed evaluation keeps result ownership with the expression executor for reset/free; the new UT defers input/result vector cleanup before executing the decoder. No new ownership transfer or double cleanup.
Q2: termination Both changed branches return synchronously; no retry, lock, channel, RPC, or background worker was introduced.
Q3: retained growth No new persistent buffer or collection. Scratch lifetime and result reuse/free boundaries are unchanged; test data and fixture count are small and fixed.

Evidence reused from the current head, CI run 36036487031: UT (including the function package in the race group), coverage, SCA, shared build, and both active Compose BVT jobs passed. The merged coverage artifact shows execution of both changed return branches. The PROXY BVT log explicitly reports vector_base64_invalid_input.sql: 11 total, 11 successful, 0 failed/ignored/abnormal, 0.058 s. The PR also records focused normal-mode tests and two standalone comparison runs. No duplicate local suite was needed; git diff --check passed.

This is an ordinary local error-classification fix (R2 public error contract), so a new design document or distributed/GPU validation requirement would be disproportionate. No blocking correctness, cleanup, test-quality, or overengineering issue found.

Submitted as a COMMENT review because the authenticated account is also the PR author; GitHub does not allow self-approval.

This branch was previously deployed

1 inactive deployment
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 size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: vector Base64 decoders report malformed input as internal errors

2 participants