fix: AdminClient::listTenants range end-key now uses KeyUtil::strinc() (#37) - #64
Merged
Conversation
#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
AdminClient::listTenants()usedself::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 byte0xFF.The scan range was effectively
[prefix, prefix . "\\\\xff"), which ends at byte0x5C. Any tenant whose name starts with a byte>= 0x5C(i.e. all lowercase lettersa-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 aRuntimeExceptionguard in casestrinc()returnsnull.Tests added
tenantRangeEndKeyIsStrictlyGreaterThanPrefix— verifies end key > prefixtenantRangeEndKeyCoversAllPossibleTenantNames— verifies all possible first bytes (0x00–0xFF) produce keys within[prefix, end)Closes #37