Skip to content

Enforce queue entry type boundary across acknowledge/requeue API#383

Open
ianks wants to merge 1 commit intomainfrom
ianks/queue-entry-type-boundary
Open

Enforce queue entry type boundary across acknowledge/requeue API#383
ianks wants to merge 1 commit intomainfrom
ianks/queue-entry-type-boundary

Conversation

@ianks
Copy link
Contributor

@ianks ianks commented Mar 25, 2026

Situation

Following #381, the codebase still conflated queue entries (JSON records) and plain test ID strings — passing both through acknowledge, requeue, and Lua scripts. This caused JSON::ParserError crashes in production when a plain string hit a JSON-only code path.

Execution

Established a clean type boundary: acknowledge/requeue accept queue entries (JSON), Lua scripts use the full entry as Redis keys. Read-side methods (failed_tests, requeued_tests, etc.) extract test_ids for display.

Using the full entry (test_id + file_path) as the Redis key — not just test_id — is intentional: in lazy streaming mode, two files can define the same test_id with different implementations. Since files are lazy-loaded, we can't depend on Ruby's method override semantics to make the test unique at queue time. The entry (which includes file_path) is the true identity.

Also fixed a latent bug where try_to_reserve_lost_test checked key('completed') but acknowledge writes to key('processed')... different Redis keys. Every timed out test looked unprocessed and got re-reserved. This has been broken since 2021 (bfc2bb1) but was masked because heartbeats rarely missed.

@ianks ianks force-pushed the ianks/queue-entry-type-boundary branch 5 times, most recently from 3df35fe to 82f31fc Compare March 26, 2026 02:31
@ianks ianks marked this pull request as ready for review March 26, 2026 02:54
@ianks ianks force-pushed the ianks/queue-entry-type-boundary branch 2 times, most recently from 744c478 to de1d2ef Compare March 26, 2026 04:10
@ianks ianks requested a review from danielahrnsbrak March 26, 2026 04:44
All queue entries are now consistently JSON. acknowledge/requeue accept
queue entries (JSON strings), not plain test IDs or test objects.
Lua scripts use the full entry as Redis hash keys instead of test_id,
eliminating the type ambiguity that caused JSON::ParserError crashes.
@ianks ianks force-pushed the ianks/queue-entry-type-boundary branch from de1d2ef to fc66d7c Compare March 26, 2026 04:47
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.

1 participant