Skip to content

[Bug]: Python SDK cannot clear a stage comment #30964

Closed

Description

@MatrixAdventurer

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

68fe0510515a4b9a005279c3e2e8d16dc860b5bb

Other Environment Information

  • Python 3.12.14
  • SQLAlchemy 2.1
  • Offline reproduction against the exact current-main blobs for stage.py and test_stage_sql.py.

Actual Behavior

StageManager.alter(name, comment='') and AsyncStageManager.alter(name, comment='') raise ValueError before sending SQL. The shared _prepare_alter() validator uses truthiness for comment, even though the SQL builder accepts an empty string and MatrixOne supports ALTER STAGE ... SET COMMENT=''.

This prevents SDK users from clearing an existing stage comment.

Expected Behavior

An explicitly supplied empty comment should generate ALTER STAGE <name> SET COMMENT=''. Calls with no option, an empty URL, or empty credentials should retain their existing validation errors.

Steps to Reproduce

manager.alter('my_stage', comment='')
# ValueError: At least one of url, credentials, comment, or enable must be provided

The same failure occurs through AsyncStageManager.alter().

Additional information

The defect is in the shared sync/async validation boundary. A minimal fix changes only the comment presence check to comment is not None and adds public-path sync/async regressions plus negative controls.

Activity

  1. XuPeng-SH commented on Oct 23, 2026

    @XuPeng-SH
    Contributor

    QA follow-up for PR #30965 at head 9eddc6b4680fae09a119c967ad5499814aaa89f3: the formal approval review reports the sync/async empty-comment regressions and negative controls passing across its offline CI matrix, with supplemental mocked-executor scenarios and source tracing. This supports the validator fix for the reported bug. The workspace here has no MatrixOne checkout, and no live service or persistence test was run in this QA pass; please retain live stage-comment persistence as a follow-up verification. Handing the still-open issue to Ariznawlll for that verification.

  2. XuPeng-SH commented on Oct 24, 2026

    @XuPeng-SH
    Contributor

    Additional live QA evidence for merged PR #30965 is now complete.

    • Tested SDK source: pinned latest main 0abc1d317aea608f3a228297d68e1ae4e619a3a2; the changed clients/python/matrixone/stage.py blob is 1a89e7a327a41b9d3a04be40714c1d15a81e222c at both merge 8111f870f5d8cee40c53fc48bcbcde8292da1fa5 and pinned main.
    • Exact pre-merge package from first parent f8c872001603fed3d23784e1ada26f9a2d8f4fba reproduced the bug through both public sync and async alter(comment=''): each raised ValueError, and a second SQL session still read the prior comment.
    • With pinned-main SDK source, both public sync and async paths emitted ALTER STAGE <name> SET COMMENT=''; metadata read through independent sessions returned an empty comment. Negative controls for no options, url='', and credentials={} still raised ValueError, executed zero SQL statements, and preserved the existing comment; a valid clear succeeded after each sequence.
    • Both test stages and fresh per-run databases were dropped and verified absent.

    This used the owned local service at 127.0.0.1:60220, version 8.0.30-MatrixOne-v1.3.0, binary source 6f773c556d4f3177f5373eb193cd576e080b662f (SHA-256 51489b59a60310e79eddcf1182c582685b2c60f800f35a0a625eb5359469349b). No service build was performed; this is a Python SDK change validated against the existing local backend. The issue-specific live behavior and negative controls passed. Existing Ariznawlll assignment was already in place and was left unchanged.

  3. Ariznawlll commented on Oct 24, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:官方 main;commit:a1888d62f89232a9bbe5830881b4f9b4d749cf42(修复 PR fix(python-sdk): allow clearing stage comments #30965 的 merge commit 8111f870f5d8cee40c53fc48bcbcde8292da1fa5 为其祖先)。
    • 部署方式:隔离本地 macOS arm64,1 LogService / 1 TN / 1 CN,独立数据库;SDK 源码与服务均取上述 main。服务二进制 SHA-256:6cb033ea67757407ebdb946f784366b3a7819a11c61cd1a0fb4dac7a7ea1caab;构建元数据 vcs.revision 为上述 SHA,工作树已跟踪源码无改动。
    • 测试日期:2026-10-24(北京时间);Python 3.11.4、SQLAlchemy 2.0.45。

    原问题验证

    通过 Python SDK 公开 Client.stage 和 AsyncClient.stage API 创建 comment 为 before 的临时 stage,再调用 alter(comment='')。同步、异步各连续 3 轮均成功;每次使用另一独立 SQL 连接读取 mo_catalog.mo_stages,实际 comment 为长度 0 的空字符串,非旧值或 NULL。PR #30965 已合入当前 main。

    Happy Path 覆盖

    1. 同步和异步 stage 的创建、清空 comment、独立连接读回均各 3/3;每轮生成唯一 stage 名并在 finally 中删除。

    Unhappy Path 覆盖

    1. 在清空前对同一 stage 分别调用无选项、url=''、credentials={}:同步/异步均抛 ValueError;独立连接复查 comment 仍为 before,各 3/3。之后合法清空仍可成功,证明失败没有污染状态。

    白盒验证

    在同一 main SDK 源码上,tests/offline/test_query_execution_state.py 与 test_stage_sql.py 合计 57 项各跑 3 轮,均通过;该问题是 Python 参数存在性校验,不适用 Go race。

    回归测试

    PR #30965 已在 clients/python/tests/offline/test_stage_sql.py 添加同步/异步清空与无效选项回归;本轮另用隔离真实服务脚本 /private/tmp/qa_sdk_a188_stage.py 补持久化读回。MOTR SQL 不能覆盖 Python SDK 的 None 与空字符串校验,未新增 PR。PR 的 Python SDK offline CI 和 CI Required 成功,online CI 跳过;本轮定向在线 3 轮通过,未跑全量 SDK/SQL BVT。

    测试证据

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions