fix: strip multi-digit array indices from query string#5
Merged
JasonHolderness-bl merged 1 commit intoMay 20, 2026
Merged
Conversation
The array-bracket cleanup regex in QueryStringCleanerMiddleware and LeverClient::prepareOptions() was '/%5B[0-9]%5D/', which only matches single-digit indices. Calling the same builder method more than 10 times (e.g. ->posting($id) for 11+ posting IDs) accumulated indices into the query string, but only %5B0%5D-%5B9%5D were stripped — leaving posting_id[10]=..., posting_id[11]=..., etc. in the final URL, which the Lever API rejects. Switched the regex to '/%5B\d+%5D/' so all numeric indices are stripped regardless of digit count. Added a regression test that calls ->posting() 12 times and asserts the resulting URL contains exactly 12 'posting_id=' parameters with no array brackets or %5B in the output.
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.
Problem
QueryStringCleanerMiddleware::buildQuery()andLeverClient::prepareOptions()both use:That pattern matches
%5B+ exactly one digit +%5D, so it strips%5B0%5Dthrough%5B9%5Dbut leaves%5B10%5D,%5B11%5D, ... intact.When a caller chains the same builder method more than 10 times, e.g.:
http_build_query()indexes the array, the regex strips the first ten, and the final URL is a mix of clean and array-indexed parameters:Lever's API rejects these requests, causing downstream production errors.
Fix
Switch both regexes to
/%5B\d+%5D/so any numeric index is stripped regardless of digit count. Behavior for batches ≤10 is unchanged.Test
Added
OpportunitiesTest::retrieve_opportunities_with_more_than_ten_postings_strips_all_array_indices, which calls->posting()12 times and asserts:%5B(URL-encoded[) anywhere in the URLposting_id[(decoded form) does not appearposting_id=parametersI verified the new test fails against the old single-digit regex and passes with the multi-digit fix. Existing test suite (17 tests, 56 assertions) remains green.
Downstream context
Found while debugging Bugsnag errors in a Laravel app that batches up to ~30
posting_idparameters in a singleopportunitiesrequest. The application now bypasses the fluent builder as a workaround; once this fix is released we can drop the workaround.