Skip to content

fix: AdminClient::listTenants range end-key now uses KeyUtil::strinc() (#37) - #64

Merged
s2x merged 1 commit into
masterfrom
fix/issue-37-listtenants-endkey
Jul 4, 2026
Merged

fix: AdminClient::listTenants range end-key now uses KeyUtil::strinc() (#37)#64
s2x merged 1 commit into
masterfrom
fix/issue-37-listtenants-endkey

Conversation

@s2x

@s2x s2x commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Bug

AdminClient::listTenants() used self::TENANT_MAP_PREFIX . '\''\\xff'\'' to compute the end of the tenant range scan. Because the literal is in single quotes, PHP interprets '\''\''\''xff\'\' as the four literal ASCII bytes \\ (0x5C), x (0x78), f (0x66), f (0x66) — not the byte 0xFF.

The scan range was effectively [prefix, prefix . "\\\\xff"), which ends at byte 0x5C. Any tenant whose name starts with a byte >= 0x5C (i.e. all lowercase letters a-z, and the characters \\, ], ^, _, ''' \`) was silently omitted from the result.

Fix

Replaced the literal concatenation with KeyUtil::strinc(self::TENANT_MAP_PREFIX), which correctly computes the exclusive end key as the strict successor of the prefix. Also added a RuntimeException guard in case strinc() returns null.

Tests added

  • tenantRangeEndKeyIsStrictlyGreaterThanPrefix — verifies end key > prefix
  • tenantRangeEndKeyCoversAllPossibleTenantNames — verifies all possible first bytes (0x00–0xFF) produce keys within [prefix, end)

Closes #37

#37)

The end-key for the tenant range scan was computed with a single-quoted
'\xff' literal, which PHP interprets as the 4-byte ASCII string \xff
(0x5C 0x78 0x66 0x66) instead of byte 0xFF. This caused the scan to
omit all tenants whose name's first byte is >= 0x5C — i.e. essentially
all lowercase-letter names.

Fix: use KeyUtil::strinc(self::TENANT_MAP_PREFIX) to correctly compute
the exclusive end key. Add unit tests verifying the end-key computation
and that all possible tenant name bytes fall within the range.
@s2x
s2x merged commit fd9989d into master Jul 4, 2026
6 checks passed
@s2x
s2x deleted the fix/issue-37-listtenants-endkey branch July 4, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] AdminClient::listTenants range end-key uses literal backslash-xff string

1 participant