Skip to content

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

Closed

Description

@Ariznawlll

Bug Report

1. Environment

  • MatrixOne commit: 95b1d2bfd9d756d08320569858080cb16f230fff
  • Local launch mode

2. What happened

The six public vector Base64 decoding functions classify ordinary malformed user input as MatrixOne internal errors (ERROR 20101):

  • VECF32_FROM_BASE64
  • VECF64_FROM_BASE64
  • VECF16_FROM_BASE64
  • VECBF16_FROM_BASE64
  • VECINT8_FROM_BASE64
  • VECUINT8_FROM_BASE64

There are two affected input classes:

  1. text that is not valid Base64;
  2. valid Base64 whose decoded byte length is not a multiple of the selected vector element width.

3. Reproduction

SELECT VECF32_FROM_BASE64('!!!');
SELECT VECF64_FROM_BASE64('!!!');
SELECT VECF16_FROM_BASE64('!!!');
SELECT VECBF16_FROM_BASE64('!!!');
SELECT VECINT8_FROM_BASE64('!!!');
SELECT VECUINT8_FROM_BASE64('!!!');

SELECT VECF32_FROM_BASE64('AA==');
SELECT VECF64_FROM_BASE64('AA==');
SELECT VECF16_FROM_BASE64('AA==');
SELECT 1 AS recovery;

4. Actual behavior

Malformed Base64:

ERROR 20101 (HY000): internal error: vec_from_base64: invalid base64 input

Decoded-length mismatch, for example VECF32_FROM_BASE64('AA=='):

ERROR 20101 (HY000): internal error: vec_from_base64: decoded length 1 is not a multiple of 4 bytes

The same result was reproduced in three consecutive executions. The connection remains usable after each error.

Control cases:

  • Valid round trips for F32/F64 and valid raw payloads for F16/BF16/INT8/UINT8 all decode correctly.
  • FROM_BASE64('!!!') returns SQL NULL and does not expose an internal error.

5. Expected behavior

Malformed function arguments should be reported as an invalid-input/data error (or the function's documented nullable result), not as an internal MatrixOne failure.

6. Code location

pkg/sql/plan/function/func_unary.go currently constructs internal errors directly for both user-input branches:

n, err := base64.StdEncoding.Decode(buf, data)
if err != nil {
    return moerr.NewInternalErrorNoCtx("vec_from_base64: invalid base64 input")
}

if n%elemSize != 0 {
    return moerr.NewInternalErrorNoCtxf(
        "vec_from_base64: decoded length %d is not a multiple of %d bytes", n, elemSize)
}

These branches should use a user-input error class rather than NewInternalErrorNoCtx*.

Activity

  1. added this to the MO-202609 milestone on Sep 24, 2026
  2. added
    kind/bug
    on Sep 24, 2026
  3. added theissue type on Sep 24, 2026
  4. self-assigned this
    on Sep 24, 2026
  5. added a commit that references this issue on Sep 24, 2026
    7cf7dbb
  6. Ariznawlll commented on Sep 27, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:5be6cd90b501da225be591ffffe6000bf01f515e
    • 部署方式:本地单机(1 CN / 1 TN / 1 LogService)
    • 测试日期:2026-09-27

    原问题验证

    在上述最新 main 上按 issue 原始复现步骤执行,并独立重复 3 次;3/3 均满足修复后的预期。当前 main 已包含修复提交 7cf7dbb6200d2cefbe826152a7c76a9ae1b2a177。

    Happy Path 覆盖

    1. 六个公开 vector Base64 decoder 对格式错误输入均使用 invalid-input 分类,合法 UINT8 payload 正常。

    Unhappy Path 覆盖

    1. 覆盖非法 Base64 和元素宽度不整除两类输入,均返回 20301,错误后合法查询成功。

    白盒验证

    确认修复提交 7cf7dbb6200d2cefbe826152a7c76a9ae1b2a177 是当前 main 的祖先,并核对对应 MatrixOne BVT/实现路径;本次另以公开 SQL 协议执行黑盒验收。

    回归测试

    已加入 MOTR PR #204 的 issue_29323_29325_29327_29328_29329_29330_29331_sql_contracts.test,MOTR 提交 2b4462f2;本地基线比对连续 3 次通过。

    测试证据

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions