Repository navigation
Description
Description
Invalid percentile arguments return internal Go stack frames and absolute source paths to the SQL client instead of a concise user-facing invalid-input error.
The query does not crash the CN, but its expected validation path is routed through panic recovery.
Environment
- MatrixOne: latest official
main, commit07fdd4ae0f80f287b93fc4b525fd296d5617abc7 - Deployment: local standalone launch (isolated Log/TN/CN ports and data directory)
Reproduction
create table t(x double);
insert into t values (10),(20),(30);
select approx_percentile(x,-1) from t;
select approx_percentile(x,cast('NaN' as double)) from t;
select percentile_cont(1.1) within group(order by x) from t;Actual behavior
The client response begins with the correct validation message, then includes internal frames and build paths:
ERROR 20301 (HY000): invalid input: percentile argument of approx_percentile
must be finite and in [0,1], got -1:
github.com/matrixorigin/matrixone/pkg/sql/compile.constructAggregateConfig
/private/tmp/matrixone-main-20260912/pkg/sql/compile/operator.go:1966
github.com/matrixorigin/matrixone/pkg/sql/compile.constructGroup
/private/tmp/matrixone-main-20260912/pkg/sql/compile/operator.go:1899
...
Negative/above-one/NaN/Inf values reproduce the stack for APPROX_PERCENTILE; exact PERCENTILE_CONT/DISC uses the adjacent path and behaves the same. Reproduced in 3/3 runs.
Expected behavior
The SQL client should receive only the stable invalid-input message. Expected user input validation must not expose panic frames or server build paths.
Controls
- valid
p=0,0.5, and1return correct minimum/median/maximum values; - NULL and nonconstant percentile arguments return concise validation errors without the same long stack;
- the service remains available after each query.
Code-path analysis
constructAggregateConfig in pkg/sql/compile/operator.go validates percentile configuration, then calls panic(err) for ordinary invalid-input results from validation, constant evaluation, and config parsing. Compile panic recovery decorates the error with frames before returning it through the MySQL protocol. This is analogous to closed #26980, which fixed unsupported time-window units being logged/returned through compile panic rather than normal error flow.
Suggested regression coverage
- below-zero, above-one, NaN, ±Inf, NULL, and nonconstant percentile arguments;
- approximate and ordered-set percentile variants;
- assert error code/message and absence of stack frames/source paths;
- verify the CN remains healthy after repeated errors.
Duplicate search
Open and closed issues were searched for percentile stack traces, constructAggregateConfig, source paths in SQL errors, and compile panic validation. #26980 concerns time-window units, not percentile configuration.
Activity
fix: return aggregate configuration errors (#28927)
Ariznawlll commentedon Sep 17, 2026
测试版本
main8e8e1998ef02b1f6233ddb1c2d3208f3b70d2d83原问题验证
对
approx_percentile和percentile_cont传入越界 percentile。均返回用户可读的ERROR 20301,不再暴露内部错误;合法边界0、0.5、1分别返回 1、5、9。Happy Path 覆盖
覆盖两个函数和 0/0.5/1 三个合法 percentile 边界。
Unhappy Path 覆盖
覆盖负数和大于 1 的 percentile;均验证为稳定的
20301业务错误。白盒验证
不适用:错误码、错误文本以及合法结果为该接口的可观察契约。
回归测试
已加入 MOTR PR #181:
issue_28870_percentile_errors.test。本地连续 3 轮通过。测试证据
motr --repeat 3 14_issue_regression.issue_28870_percentile_errors:3/3 通过,9 条 SQL/轮均成功。测试结论
测试通过。
fix: return aggregate configuration errors (matrixorigin#28927)
fix: return aggregate configuration errors (matrixorigin#28927)