[Django] #37002: Off-by-one error in parallel test worker index validation

12 views
Skip to first unread message

Django

unread,
Mar 24, 2026, 12:42:48 PMMar 24
to django-...@googlegroups.com
#37002: Off-by-one error in parallel test worker index validation
-------------------------------------+-------------------------------------
Reporter: Shashank Kushwaha | Type: Bug
Status: new | Component: Testing
| framework
Version: 6.0 | Severity: Normal
Keywords: parallel testing, | Triage Stage:
off-by-one, worker-id | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
In django/test/runner.py, the validation of _worker_id uses:

if _worker_id > len(db_aliases):

However, valid worker IDs should range from 0 to len(db_aliases) - 1.

For example, if len(db_aliases) = 3, valid IDs are 0, 1, and 2. The
current condition allows _worker_id == 3, which is invalid.

This appears to be an off-by-one error and should likely use:

if _worker_id >= len(db_aliases):

This was observed while reviewing PR #20971.
--
Ticket URL: <https://code.djangoproject.com/ticket/37002>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 24, 2026, 12:43:31 PMMar 24
to django-...@googlegroups.com
#37002: Off-by-one error in parallel test worker index validation
-------------------------------------+-------------------------------------
Reporter: Shashank Kushwaha | Owner: (none)
Type: Bug | Status: new
Component: Testing framework | Version: 6.0
Severity: Normal | Resolution:
Keywords: parallel testing, | Triage Stage:
off-by-one, worker-id | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Shashank Kushwaha):

i'd like to work on this , if accepted.
--
Ticket URL: <https://code.djangoproject.com/ticket/37002#comment:1>

Django

unread,
Mar 24, 2026, 1:08:54 PMMar 24
to django-...@googlegroups.com
#37002: Off-by-one error in parallel test worker index validation
-------------------------------------+-------------------------------------
Reporter: Shashank Kushwaha | Owner: (none)
Type: Bug | Status: closed
Component: Testing framework | Version: 6.0
Severity: Normal | Resolution: fixed
Keywords: parallel testing, | Triage Stage:
off-by-one, worker-id | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Shashank Kushwaha):

* resolution: => fixed
* status: new => closed

Comment:

It looks like this issue has been addressed in PR #20971 by adding
validation for `_worker_id >= len(db_aliases)` before usage.

I’m marking this as fixed. Happy to close if no further action is needed.
--
Ticket URL: <https://code.djangoproject.com/ticket/37002#comment:2>

Django

unread,
Mar 24, 2026, 1:26:13 PMMar 24
to django-...@googlegroups.com
#37002: Off-by-one error in parallel test worker index validation
-------------------------------------+-------------------------------------
Reporter: Shashank Kushwaha | Owner: (none)
Type: Bug | Status: closed
Component: Testing framework | Version: 6.0
Severity: Normal | Resolution: duplicate
Keywords: parallel testing, | Triage Stage:
off-by-one, worker-id | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* resolution: fixed => duplicate

Comment:

Duplicate of #27734
--
Ticket URL: <https://code.djangoproject.com/ticket/37002#comment:3>
Reply all
Reply to author
Forward
0 new messages