You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "thswlsqls (via GitHub)" <gi...@apache.org> on 2026/08/06 23:08:46 UTC

[I] MASK_FROM_X_TO_Y and KEEP_FROM_X_TO_Y reject the documented from-x and to-y value 0 [shardingsphere]

thswlsqls opened a new issue, #39362:
URL: https://github.com/apache/shardingsphere/issues/39362

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   
   master @ 99a0b47786f
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   Both
   
   ### Expected behavior
   
   `from-x: 0` and `to-y: 0` are accepted by `MASK_FROM_X_TO_Y` and `KEEP_FROM_X_TO_Y`. Both `mask.en.md` and `mask.cn.md` define them as 0-based: `from-x | int | start position (from 0)`, `to-y | int | end position (from 0)`.
   
   ### Actual behavior
   
   Initialization fails with `AlgorithmInitializationException: from-x must be a positive integer.`, so masking a value from its very first character cannot be configured at all.
   
   ### Reason analyze (If you can)
   
   `MaskFromXToYMaskAlgorithm.createFromX()/createToY()` (`features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java:55,60`) and `KeepFromXToYMaskAlgorithm` (same lines) call `MaskAlgorithmPropertiesChecker.checkPositiveInteger()`, which asserts `integerValue > 0` (`MaskAlgorithmPropertiesChecker.java:70`). That checker is right for the count-typed `first-n`/`last-m`, but `from-x`/`to-y` are positions and must allow 0. The runtime is already 0-based: `MaskFromXToYMaskAlgorithm.mask():80` uses `fromX` directly as a char array index.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   ```sql
   CREATE MASK RULE t_user (
   COLUMNS((NAME=phone, TYPE(NAME='MASK_FROM_X_TO_Y', PROPERTIES('from-x'='0', 'to-y'='2', 'replace-char'='*'))))
   );
   ```
   
   The equivalent YAML `!MASK` rule fails at startup for the same reason.
   
   ### Example codes for reproduce this issue (such as a github link).
   
   N/A
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] MASK_FROM_X_TO_Y and KEEP_FROM_X_TO_Y reject the documented from-x and to-y value 0 [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #39362: MASK_FROM_X_TO_Y and KEEP_FROM_X_TO_Y reject the documented from-x and to-y value 0
URL: https://github.com/apache/shardingsphere/issues/39362


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org