Start and stop offsets are swapped in sharding value offset error message

Author: thswlsqlsCreated Sep 17, 2026Updated Sep 17, 2026

Bug Report

Which version of ShardingSphere did you use?

master @ 101c3d56ccd

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

Both

Expected behavior

Error 20023 reports the stop offset first and the start offset second, as documented in docs/document/content/user-manual/error-code/sql-error-code.en.md line 174. With start-offset: 10, stop-offset: 1 and sharding value 1:

Sharding value 1 subtract stop offset 1 can not be less than start offset 10.

Actual behavior

The two offsets are swapped: Sharding value 1 subtract stop offset 10 can not be less than start offset 1.

Reason analyze (If you can)

ShardingValueOffsetException (features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/data/ShardingValueOffsetException.java line 31) passes startOffset, stopOffset to a format string whose placeholders are ordered stop first, start second. The only caller, ModShardingAlgorithm.cutShardingValue() line 141, passes arguments in declared order, so only the super call is wrong.

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

Configure a MOD sharding algorithm with start-offset plus stop-offset not less than the sharding value length, then route a query with that value. The client receives SQLState 44000, vendor code 20023.

Example codes for reproduce this issue (such as a github link).

N/A