Repository navigation
Description
DRAFT 11 (SDK, 2026-10-27) — to be filed
Title: [Bug]: StageManager drops enable=False on CREATE and interpolates URLs/credentials/comments unescaped
Description
Two defects in BaseStageManager SQL builders (stage.py:256-336):
1. enable parameter is silently ignored on CREATE
def _build_create_stage_sql(self, stage_name, url, credentials=None, enable=True, comment=None, if_not_exists=False):
sql_parts = ["CREATE STAGE"]
...
# Note: enable is not included in SQL - MatrixOne stages are enabled by default
return " ".join(sql_parts)The public API accepts enable (documented as whether the stage is enabled), but the builder never emits it. create_stage(..., enable=False) creates an enabled stage with no warning. Meanwhile the same file's _build_alter_stage_sql supports ENABLE=TRUE/FALSE (line ~314) — so the grammar exists; CREATE just doesn't use it, and the two paths disagree about the feature. (Create-side disabled stages are a real use case: pre-provisioning stages without activating them — RESTRICTED/audit workflows.)
2. Raw interpolation of URL / credentials / comment / WHERE value
sql_parts.append(stage_name) # "No escaping to match existing behavior" (code comment admits it)
sql_parts.append(f"URL='{url}'")
cred_parts = [f"'{k}'='{v}'" for k, v in credentials.items()] # S3 keys/secrets!
sql_parts.append(f"COMMENT='{comment}'")
... f"WHERE stage_name = '{stage_name}'"- A value containing
'breaks the statement or rewrites it — and thecredentialsparam carries AWS secrets: a secret with a quote (common in templated secret strings) corrupts the CREATE STAGE statement and the raw secret can leak into error logs (server 1064 messages echo the SQL). stage_nameunquoted-identifier + unescaped WHERE literal round out the family. Comments say "matching existing behavior" as if that were compliance rather than the bug.
Reproduction
client.stage.create_stage(
"my_stage",
url="s3://bucket/path",
credentials={"aws_key_id": "AKIA...'", "aws_secret_key": "secret'with'quotes"},
enable=False,
)
# emitted: CREATE STAGE my_stage URL='s3://bucket/path' CREDENTIALS={'aws_key_id'='AKIA...'', ...}
# 1) server error echoes the malformed SQL (secret leaked into logs); 2) stage is created ENABLED despite enable=False
client.stage.get_stage("x' OR stage_name = 'y")
# emitted: ... WHERE stage_name = 'x' OR stage_name = 'y' (returns another tenant-visible stage row if name-collision)Impact
enable=Falsebeing a no-op silently breaks pre-provisioning flows; the user has no way to know besides inspecting SHOW STAGES output later (stage_status reads enabled). Worse, the docstring and signature promise the behavior.- Credentials-corruption leaks secrets via error echoes — the single most sensitive data the SDK handles.
- The code comments ("No escaping to match existing behavior") actively normalize the defect; any future escaping fix needs to remove those and use the (currently no-op — [Bug]: SDK _escape_string/_escape_identifier are no-ops that only wrap quotes #31375) escape helpers once fixed, or bind-parameters.
Expected behavior
- CREATE STAGE must honor
enable— emitENABLE = TRUE/FALSE(parity with ALTER's own grammar in the same file) or drop the parameter with a clear NotImplementedError rather than silently ignoring. - Escape every literal: URL/comment/credential values via
'-doubling (fixed helper once [Bug]: SDK _escape_string/_escape_identifier are no-ops that only wrap quotes #31375 lands), stage_name via backticks (doubling), andget_stagevia bindparams (WHERE stage_name = :name) since the SDK already depends on SQLAlchemy connection execution. - Regression: stage names/values containing
',{, spaces; enable=False asserting SHOW STAGES reads disabled; credentials round-trip asserting the stored URL/status (not secrets).
Activity
fix(python-sdk): honor enable=False when creating a stage (#31522)
XuPeng-SH commentedon Oct 28, 2026
QA on merged SDK
f97056d1107a89854bfac2c06202698e3aafd41e(#31522): the offline stage/moctl files passed 67 tests, including sync/async disabled-stage SQL and default SQL. Additional release-boundary and metadata offline tests passed 31 cases, including a quoted stage comment/identifier and rejection of backslash/NUL in stage string tokens. These establish SDK SQL generation and safe input handling for those cases; they do not establish the server's stored status.The original acceptance explicitly asks for
SHOW STAGESto read disabled, and stored URL/status with synthetic quoted credential inputs. Those server readbacks have not been run here. The older83c1server may be suitable for the SDK contract with mixed-version provenance, but the present resource headroom under the existing guard is insufficient to safely start it. Handing off to QA for those specific checks.Ariznawlll commentedon Oct 28, 2026
结论
测试不通过。创建禁用 stage 的状态读回正常,但原 issue 要求覆盖的带单引号 comment 仍无法通过真实 SDK 创建,离线 SQL 生成通过不代表服务端接受该输入。
关键证据
main@9eb05ce0f5ac5ddce36024aaa21c4c79d3e4334c,包含 SDK 修复 PR #31522;本地隔离 1 Log + 1 TN + 2 CN,连接一个 CN,Python SDK 与服务端版本一致。client.stage.create(name, url='file:///tmp/', enable=False, comment="qa 'quoted' comment"),3 个不同 stage 名称均返回QueryError/ 服务端 1105 语法错误(3/3);SDK 实际生成的 SQL 为CREATE STAGE <name> URL='file:///tmp/' ENABLE=FALSE COMMENT='qa ''quoted'' comment'。失败后检查及清理测试 stage。COMMENT='plain comment'创建后读回stage_status=disabled;SQL 单引号加倍和反斜杠两种引号写法均返回 1105,重复各 3/3。说明问题至少涉及服务端 stage 语法/执行路径,尚不能断言仅由 SDK 造成。enable=False读回disabled,再改为enable=True读回enabled,同步创建与异步读取 3/3;非法反斜杠及 NUL URL 被 SDK 拒绝。均为本地合成输入,未使用实际凭据。待解决点
fix(python): unify SDK query and analytics lifecycle contracts (#31774)
XuPeng-SH commentedon Oct 30, 2026
QA handoff for merged #31774 (main
bbfe55669a1440424914d45a283a1d0e36f722fa): please verify Stage creation/alter with quoted values, status and native readback. This isolated QA run inspected the issue and merged source but did not run tests or a live MatrixOne service at this SHA because resource headroom under the existing guard was insufficient. Earlier QA counterexamples and PR author-reported validation remain scoped to their recorded versions and are not results of this QA run.Ariznawlll commentedon Oct 30, 2026
结论
测试通过。Stage 创建能保留禁用状态及带引号的 URL、comment 和合成凭据;之前真实服务上的引号失败已复验通过。
关键证据
main@d39d8a40343ccd40bf665036388df7a40ee867f8;修复 PR fix(python): unify SDK query and analytics lifecycle contracts #31774 的合并提交bbfe55669a1440424914d45a283a1d0e36f722fa在祖先链;运行二进制和 SDK 同完整 SHA。本地隔离 1 CN / 1 TN / 1 LogService,唯一 CN 已使用该版本,Python 3.12。enable=False后同步及异步读回均为 disabled 且值一致;异步修改为 enabled 并更新带引号 comment 后,同步读取值正确。待解决点
Ariznawlll commentedon Oct 30, 2026
回归位置更正:#295 已关闭并汇总至 MOTR #298;本 issue 的定向用例已补入 #298,之前所述测试结果及未覆盖项不变。#298 尚未合入,完整 MOTR suite 未运行。