Skip to content

Fix test_distinct_titles_keep_unsuffixed_ids failing on the 20th-29th - #323

Merged
pufit merged 1 commit into
mainfrom
pufit/task-id-test-date-flake
Aug 20, 2026
Merged

Fix test_distinct_titles_keep_unsuffixed_ids failing on the 20th-29th#323
pufit merged 1 commit into
mainfrom
pufit/task-id-test-date-flake

Conversation

@pufit

@pufit pufit commented Aug 20, 2026

Copy link
Copy Markdown
Member

tests/test_task_id_collision.py::TestSlugCollision::test_distinct_titles_keep_unsuffixed_ids fails on main today, and on 119 days a year, with nothing wrong with the code it covers.

Why

The test means "two distinct titles get ids with no -2 collision suffix", but it checks that by searching the response line for the substring -2:

assert "-2" not in first.splitlines()[0]

Task ids are date-prefixed, so from the 20th of any month the date supplies that substring itself:

Task created: 2026-08-20-rotate-the-staging-credentials (status: pending)
                       ^^

Days 20-29 of every month — 119 days in 2026. (The 1st-19th are safe: a - is only ever followed by a 2 in the day field, months being 01-12.)

Fix

Assert on the id rather than hunting for a substring: build the expected unsuffixed ids with _make_task_id (the helper this file already uses to pin collisions) and require each response to name its id verbatim.

assert f"Task created: {task_id} " in await _create(ctx, title, "x")

This keeps the test's teeth — a collision suffix would put a -2 exactly where the assertion expects the space before (status: …), so ...-credentials-2 (status: …) still fails. Verified against clean and suffixed strings across dates on both sides of the boundary, plus a harness guard that the two titles remain distinct.

Testing

pytest tests/ — 3336 passed, run today (2026-08-20), the exact date that breaks the current assertion.

Generated by Nerve

The test asserted `"-2" not in <first line of the response>` to mean "no
collision suffix was appended". Task ids carry a date prefix, so from the
20th of any month that substring matches the date itself
(`2026-08-20-rotate-…`) and the test fails — 119 days a year, on main, with
nothing wrong with the code under test.

Assert on the id instead of hunting a substring: build the expected
unsuffixed ids with `_make_task_id` and require the response to name each
one verbatim. A collision suffix would put a "-2" exactly where this
expects the space before "(status: …)", so the test still fails for the
reason it was written to catch.
@pufit
pufit merged commit fdaabdc into main Aug 20, 2026
2 checks passed
@pufit
pufit deleted the pufit/task-id-test-date-flake branch August 20, 2026 15:48
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