#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019d20ba1dec-157e6d56-2aa5-430a-80db-e73e06799e94-000000%40eu-central-1.amazonses.com.

Reply via email to