fix(preprod): fix flaky test by avoiding search field collisions#108641
Draft
fix(preprod): fix flaky test by avoiding search field collisions#108641
Conversation
test_list_builds_search_by_build_id searches with query={artifact.id}
and expects exactly 1 result. However, the search does an OR across
id, pr_number, and head_sha (icontains). The old head_sha
"1234567890..." contained most small numbers as substrings, and
pr_number=123 could collide with auto-incremented artifact IDs.
Use an all-letter hex head_sha and a large pr_number to prevent
auto-incremented IDs from accidentally matching other search fields.
Fixes #108637
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| head_sha="1234567890098765432112345678900987654321", | ||
| base_sha="9876543210012345678998765432100123456789", | ||
| head_sha="abcdefabcdefabcdefabcdefabcdefabcdefabcd", | ||
| base_sha="fedcbafedcbafedcbafedcbafedcbafedcbafedcb", |
Contributor
There was a problem hiding this comment.
base_sha is 41 characters instead of 40
Low Severity
The new base_sha value "fedcbafedcbafedcbafedcbafedcbafedcbafedcb" is 41 characters long, while a valid SHA-1 hash is exactly 40 hex characters. The head_sha correctly uses the pattern "abcdef" × 6 + "abcd" = 40 chars, but base_sha uses "fedcba" × 6 + "fedcb" = 41 chars. The trailing "fedcb" has one extra character compared to the "abcd" suffix of head_sha.
Member
Author
|
why is fedcbafedcbafedcbafedcbafedcbafedcbafedcb 1 character extra? seems wrong |
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.


Summary
test_list_builds_search_by_build_idsearches withquery={artifact.id}and expects 1 result, but the endpoint's search does an OR query acrossid,pr_number, andhead_sha(icontains)head_sha("1234567890...") contained most small numbers as substrings, causing auto-incremented artifact IDs to accidentally match all 4 artifacts viahead_sha__icontainspr_number=123could collide with auto-incremented artifact IDshead_shato all-letter hex ("abcdefab...") andpr_numberto99000123to eliminate collisionsFixes #108637