1. ================
    
  2. Triaging tickets
    
  3. ================
    
  4. 
    
  5. Django uses Trac_ for managing the work on the code base. Trac is a
    
  6. community-tended garden of the bugs people have found and the features people
    
  7. would like to see added. As in any garden, sometimes there are weeds to be
    
  8. pulled and sometimes there are flowers and vegetables that need picking. We need
    
  9. your help to sort out one from the other, and in the end, we all benefit
    
  10. together.
    
  11. 
    
  12. Like all gardens, we can aspire to perfection, but in reality there's no such
    
  13. thing. Even in the most pristine garden there are still snails and insects.
    
  14. In a community garden there are also helpful people who -- with the best of
    
  15. intentions -- fertilize the weeds and poison the roses. It's the job of the
    
  16. community as a whole to self-manage, keep the problems to a minimum, and
    
  17. educate those coming into the community so that they can become valuable
    
  18. contributing members.
    
  19. 
    
  20. Similarly, while we aim for Trac to be a perfect representation of the state of
    
  21. Django's progress, we acknowledge that this will not happen. By distributing
    
  22. the load of Trac maintenance to the community, we accept that there will be
    
  23. mistakes. Trac is "mostly accurate", and we give allowances for the fact that
    
  24. sometimes it will be wrong. That's okay. We're perfectionists with deadlines.
    
  25. 
    
  26. We rely on the community to keep participating, keep tickets as accurate as
    
  27. possible, and raise issues for discussion on our mailing lists when there is
    
  28. confusion or disagreement.
    
  29. 
    
  30. Django is a community project, and every contribution helps. We can't do this
    
  31. without **you**!
    
  32. 
    
  33. Triage workflow
    
  34. ===============
    
  35. 
    
  36. Unfortunately, not all bug reports and feature requests in the ticket tracker
    
  37. provide all the :doc:`required details<bugs-and-features>`. A number of
    
  38. tickets have patches, but those patches don't meet all the requirements of a
    
  39. :ref:`good patch<patch-style>`.
    
  40. 
    
  41. One way to help out is to *triage* tickets that have been created by other
    
  42. users.
    
  43. 
    
  44. Most of the workflow is based around the concept of a ticket's
    
  45. :ref:`triage stages <triage-stages>`. Each stage describes where in its
    
  46. lifetime a given ticket is at any time. Along with a handful of flags, this
    
  47. attribute easily tells us what and who each ticket is waiting on.
    
  48. 
    
  49. Since a picture is worth a thousand words, let's start there:
    
  50. 
    
  51. .. image:: /internals/_images/triage_process.*
    
  52.    :height: 501
    
  53.    :width: 400
    
  54.    :alt: Django's ticket triage workflow
    
  55. 
    
  56. We've got two roles in this diagram:
    
  57. 
    
  58. * Mergers: people with commit access who are responsible for making the
    
  59.   final decision to merge a patch.
    
  60. 
    
  61. * Ticket triagers: anyone in the Django community who chooses to
    
  62.   become involved in Django's development process. Our Trac installation
    
  63.   is intentionally left open to the public, and anyone can triage tickets.
    
  64.   Django is a community project, and we encourage :ref:`triage by the
    
  65.   community<how-can-i-help-with-triaging>`.
    
  66. 
    
  67. By way of example, here we see the lifecycle of an average ticket:
    
  68. 
    
  69. * Alice creates a ticket and sends an incomplete pull request (no tests,
    
  70.   incorrect implementation).
    
  71. 
    
  72. * Bob reviews the pull request, marks the ticket as "Accepted", "needs tests",
    
  73.   and "patch needs improvement", and leaves a comment telling Alice how the
    
  74.   patch could be improved.
    
  75. 
    
  76. * Alice updates the pull request, adding tests (but not changing the
    
  77.   implementation). She removes the two flags.
    
  78. 
    
  79. * Charlie reviews the pull request and resets the "patch needs improvement"
    
  80.   flag with another comment about improving the implementation.
    
  81. 
    
  82. * Alice updates the pull request, fixing the implementation. She removes the
    
  83.   "patch needs improvement" flag.
    
  84. 
    
  85. * Daisy reviews the pull request and marks the ticket as "Ready for checkin".
    
  86. 
    
  87. * Jacob, a :ref:`merger <mergers-team>`, reviews the pull request and merges
    
  88.   it.
    
  89. 
    
  90. Some tickets require much less feedback than this, but then again some tickets
    
  91. require much much more.
    
  92. 
    
  93. .. _triage-stages:
    
  94. 
    
  95. Triage stages
    
  96. =============
    
  97. 
    
  98. Below we describe in more detail the various stages that a ticket may flow
    
  99. through during its lifetime.
    
  100. 
    
  101. Unreviewed
    
  102. ----------
    
  103. 
    
  104. The ticket has not been reviewed by anyone who felt qualified to make a
    
  105. judgment about whether the ticket contained a valid issue, a viable feature,
    
  106. or ought to be closed for any of the various reasons.
    
  107. 
    
  108. Accepted
    
  109. --------
    
  110. 
    
  111. The big gray area! The absolute meaning of "accepted" is that the issue
    
  112. described in the ticket is valid and is in some stage of being worked on.
    
  113. Beyond that there are several considerations:
    
  114. 
    
  115. * **Accepted + No Flags**
    
  116. 
    
  117.   The ticket is valid, but no one has submitted a patch for it yet. Often this
    
  118.   means you could safely start writing a patch for it. This is generally more
    
  119.   true for the case of accepted bugs than accepted features. A ticket for a bug
    
  120.   that has been accepted means that the issue has been verified by at least one
    
  121.   triager as a legitimate bug - and should probably be fixed if possible. An
    
  122.   accepted new feature may only mean that one triager thought the feature would
    
  123.   be good to have, but this alone does not represent a consensus view or imply
    
  124.   with any certainty that a patch will be accepted for that feature. Seek more
    
  125.   feedback before writing an extensive patch if you are in doubt.
    
  126. 
    
  127. * **Accepted + Has Patch**
    
  128. 
    
  129.   The ticket is waiting for people to review the supplied patch. This means
    
  130.   downloading the patch and trying it out, verifying that it contains tests
    
  131.   and docs, running the test suite with the included patch, and leaving
    
  132.   feedback on the ticket.
    
  133. 
    
  134. * **Accepted + Has Patch + Needs ...**
    
  135. 
    
  136.   This means the ticket has been reviewed, and has been found to need further
    
  137.   work. "Needs tests" and "Needs documentation" are self-explanatory. "Patch
    
  138.   needs improvement" will generally be accompanied by a comment on the ticket
    
  139.   explaining what is needed to improve the code.
    
  140. 
    
  141. Ready For Checkin
    
  142. -----------------
    
  143. 
    
  144. The ticket was reviewed by any member of the community other than the person
    
  145. who supplied the patch and found to meet all the requirements for a
    
  146. commit-ready patch. A :ref:`merger <mergers-team>` now needs to give the patch
    
  147. a final review prior to being committed.
    
  148. 
    
  149. There are a lot of pull requests. It can take a while for your patch to get
    
  150. reviewed. See the :ref:`contributing code FAQ<new-contributors-faq>` for some
    
  151. ideas here.
    
  152. 
    
  153. Someday/Maybe
    
  154. -------------
    
  155. 
    
  156. This stage isn't shown on the diagram. It's used sparingly to keep track of
    
  157. high-level ideas or long-term feature requests.
    
  158. 
    
  159. These tickets are uncommon and overall less useful since they don't describe
    
  160. concrete actionable issues. They are enhancement requests that we might
    
  161. consider adding someday to the framework if an excellent patch is submitted.
    
  162. They are not a high priority.
    
  163. 
    
  164. Other triage attributes
    
  165. =======================
    
  166. 
    
  167. A number of flags, appearing as checkboxes in Trac, can be set on a ticket:
    
  168. 
    
  169. Has patch
    
  170. ---------
    
  171. 
    
  172. This means the ticket has an associated
    
  173. :doc:`patch<writing-code/submitting-patches>`. These will be reviewed
    
  174. to see if the patch is "good".
    
  175. 
    
  176. The following three fields (Needs documentation, Needs tests,
    
  177. Patch needs improvement) apply only if a patch has been supplied.
    
  178. 
    
  179. Needs documentation
    
  180. -------------------
    
  181. 
    
  182. This flag is used for tickets with patches that need associated
    
  183. documentation. Complete documentation of features is a prerequisite
    
  184. before we can check them into the codebase.
    
  185. 
    
  186. Needs tests
    
  187. -----------
    
  188. 
    
  189. This flags the patch as needing associated unit tests. Again, this
    
  190. is a required part of a valid patch.
    
  191. 
    
  192. Patch needs improvement
    
  193. -----------------------
    
  194. 
    
  195. This flag means that although the ticket *has* a patch, it's not quite
    
  196. ready for checkin. This could mean the patch no longer applies
    
  197. cleanly, there is a flaw in the implementation, or that the code
    
  198. doesn't meet our standards.
    
  199. 
    
  200. Easy pickings
    
  201. -------------
    
  202. 
    
  203. Tickets that would require small, easy, patches.
    
  204. 
    
  205. Type
    
  206. ----
    
  207. 
    
  208. Tickets should be categorized by *type* between:
    
  209. 
    
  210. * New Feature
    
  211.     For adding something new.
    
  212. 
    
  213. * Bug
    
  214.     For when an existing thing is broken or not behaving as expected.
    
  215. 
    
  216. * Cleanup/optimization
    
  217.     For when nothing is broken but something could be made cleaner,
    
  218.     better, faster, stronger.
    
  219. 
    
  220. Component
    
  221. ---------
    
  222. 
    
  223. Tickets should be classified into *components* indicating which area of
    
  224. the Django codebase they belong to. This makes tickets better organized and
    
  225. easier to find.
    
  226. 
    
  227. Severity
    
  228. --------
    
  229. 
    
  230. The *severity* attribute is used to identify blockers, that is, issues that
    
  231. should get fixed before releasing the next version of Django. Typically those
    
  232. issues are bugs causing regressions from earlier versions or potentially
    
  233. causing severe data losses. This attribute is quite rarely used and the vast
    
  234. majority of tickets have a severity of "Normal".
    
  235. 
    
  236. Version
    
  237. -------
    
  238. 
    
  239. It is possible to use the *version* attribute to indicate in which
    
  240. version the reported bug was identified.
    
  241. 
    
  242. UI/UX
    
  243. -----
    
  244. 
    
  245. This flag is used for tickets that relate to User Interface and User
    
  246. Experiences questions. For example, this flag would be appropriate for
    
  247. user-facing features in forms or the admin interface.
    
  248. 
    
  249. Cc
    
  250. --
    
  251. 
    
  252. You may add your username or email address to this field to be notified when
    
  253. new contributions are made to the ticket.
    
  254. 
    
  255. Keywords
    
  256. --------
    
  257. 
    
  258. With this field you may label a ticket with multiple keywords. This can be
    
  259. useful, for example, to group several tickets on the same theme. Keywords can
    
  260. either be comma or space separated. Keyword search finds the keyword string
    
  261. anywhere in the keywords. For example, clicking on a ticket with the keyword
    
  262. "form" will yield similar tickets tagged with keywords containing strings such
    
  263. as "formset", "modelformset", and "ManagementForm".
    
  264. 
    
  265. .. _closing-tickets:
    
  266. 
    
  267. Closing Tickets
    
  268. ===============
    
  269. 
    
  270. When a ticket has completed its useful lifecycle, it's time for it to be
    
  271. closed. Closing a ticket is a big responsibility, though. You have to be sure
    
  272. that the issue is really resolved, and you need to keep in mind that the
    
  273. reporter of the ticket may not be happy to have their ticket closed (unless
    
  274. it's fixed!). If you're not certain about closing a ticket, leave a comment
    
  275. with your thoughts instead.
    
  276. 
    
  277. If you do close a ticket, you should always make sure of the following:
    
  278. 
    
  279. * Be certain that the issue is resolved.
    
  280. 
    
  281. * Leave a comment explaining the decision to close the ticket.
    
  282. 
    
  283. * If there is a way they can improve the ticket to reopen it, let them know.
    
  284. 
    
  285. * If the ticket is a duplicate, reference the original ticket. Also
    
  286.   cross-reference the closed ticket by leaving a comment in the original one
    
  287.   -- this allows to access more related information about the reported bug
    
  288.   or requested feature.
    
  289. 
    
  290. * **Be polite.** No one likes having their ticket closed. It can be
    
  291.   frustrating or even discouraging. The best way to avoid turning people
    
  292.   off from contributing to Django is to be polite and friendly and to offer
    
  293.   suggestions for how they could improve this ticket and other tickets in
    
  294.   the future.
    
  295. 
    
  296. A ticket can be resolved in a number of ways:
    
  297. 
    
  298. * fixed
    
  299.       Used once a patch has been rolled into Django and the issue is fixed.
    
  300. 
    
  301. * invalid
    
  302.       Used if the ticket is found to be incorrect. This means that the
    
  303.       issue in the ticket is actually the result of a user error, or
    
  304.       describes a problem with something other than Django, or isn't
    
  305.       a bug report or feature request at all (for example, some new users
    
  306.       submit support queries as tickets).
    
  307. 
    
  308. * wontfix
    
  309.       Used when someone decides that the request isn't appropriate for
    
  310.       consideration in Django. Sometimes a ticket is closed as "wontfix" with a
    
  311.       request for the reporter to start a discussion on the |django-developers|
    
  312.       mailing list if they feel differently from the rationale provided by the
    
  313.       person who closed the ticket. Other times, a mailing list discussion
    
  314.       precedes the decision to close a ticket. Always use the mailing list to
    
  315.       get a consensus before reopening tickets closed as "wontfix".
    
  316. 
    
  317. * duplicate
    
  318.       Used when another ticket covers the same issue. By closing duplicate
    
  319.       tickets, we keep all the discussion in one place, which helps
    
  320.       everyone.
    
  321. 
    
  322. * worksforme
    
  323.       Used when the ticket doesn't contain enough detail to replicate
    
  324.       the original bug.
    
  325. 
    
  326. * needsinfo
    
  327.       Used when the ticket does not contain enough information to replicate
    
  328.       the reported issue but is potentially still valid. The ticket
    
  329.       should be reopened when more information is supplied.
    
  330. 
    
  331. If you believe that the ticket was closed in error -- because you're
    
  332. still having the issue, or it's popped up somewhere else, or the triagers have
    
  333. made a mistake -- please reopen the ticket and provide further information.
    
  334. Again, please do not reopen tickets that have been marked as "wontfix" and
    
  335. bring the issue to |django-developers| instead.
    
  336. 
    
  337. .. _how-can-i-help-with-triaging:
    
  338. 
    
  339. How can I help with triaging?
    
  340. =============================
    
  341. 
    
  342. The triage process is primarily driven by community members. Really,
    
  343. **ANYONE** can help.
    
  344. 
    
  345. To get involved, start by `creating an account on Trac`_. If you have an
    
  346. account but have forgotten your password, you can reset it using the `password
    
  347. reset page`_.
    
  348. 
    
  349. Then, you can help out by:
    
  350. 
    
  351. * Closing "Unreviewed" tickets as "invalid", "worksforme", or "duplicate", or
    
  352.   "wontfix".
    
  353. 
    
  354. * Closing "Unreviewed" tickets as "needsinfo" when the description is too
    
  355.   sparse to be actionable, or when they're feature requests requiring a
    
  356.   discussion on |django-developers|.
    
  357. 
    
  358. * Correcting the "Needs tests", "Needs documentation", or "Has patch"
    
  359.   flags for tickets where they are incorrectly set.
    
  360. 
    
  361. * Setting the "`Easy pickings`_" flag for tickets that are small and
    
  362.   relatively straightforward.
    
  363. 
    
  364. * Set the *type* of tickets that are still uncategorized.
    
  365. 
    
  366. * Checking that old tickets are still valid. If a ticket hasn't seen
    
  367.   any activity in a long time, it's possible that the problem has been
    
  368.   fixed but the ticket hasn't yet been closed.
    
  369. 
    
  370. * Identifying trends and themes in the tickets. If there are a lot of bug
    
  371.   reports about a particular part of Django, it may indicate we should
    
  372.   consider refactoring that part of the code. If a trend is emerging,
    
  373.   you should raise it for discussion (referencing the relevant tickets)
    
  374.   on |django-developers|.
    
  375. 
    
  376. * Verify if patches submitted by other users are correct. If they are correct
    
  377.   and also contain appropriate documentation and tests then move them to the
    
  378.   "Ready for Checkin" stage. If they are not correct then leave a comment to
    
  379.   explain why and set the corresponding flags ("Patch needs improvement",
    
  380.   "Needs tests" etc.).
    
  381. 
    
  382. .. note::
    
  383. 
    
  384.     The `Reports page`_ contains links to many useful Trac queries, including
    
  385.     several that are useful for triaging tickets and reviewing patches as
    
  386.     suggested above.
    
  387. 
    
  388.     You can also find more :doc:`new-contributors`.
    
  389. 
    
  390.     .. _Reports page: https://code.djangoproject.com/wiki/Reports
    
  391. 
    
  392. However, we do ask the following of all general community members working in
    
  393. the ticket database:
    
  394. 
    
  395. * Please **don't** promote your own tickets to "Ready for checkin". You
    
  396.   may mark other people's tickets that you've reviewed as "Ready for
    
  397.   checkin", but you should get at minimum one other community member to
    
  398.   review a patch that you submit.
    
  399. 
    
  400. * Please **don't** reverse a decision without posting a message to
    
  401.   |django-developers| to find consensus.
    
  402. 
    
  403. * If you're unsure if you should be making a change, don't make the
    
  404.   change but instead leave a comment with your concerns on the ticket,
    
  405.   or post a message to |django-developers|. It's okay to be unsure,
    
  406.   but your input is still valuable.
    
  407. 
    
  408. .. _Trac: https://code.djangoproject.com/
    
  409. .. _`easy pickings`: https://code.djangoproject.com/query?status=!closed&easy=1
    
  410. .. _`creating an account on Trac`: https://www.djangoproject.com/accounts/register/
    
  411. .. _password reset page: https://www.djangoproject.com/accounts/password/reset/
    
  412. 
    
  413. Bisecting a regression
    
  414. ======================
    
  415. 
    
  416. .. highlight:: console
    
  417. 
    
  418. A regression is a bug that's present in some newer version of Django but not in
    
  419. an older one. An extremely helpful piece of information is the commit that
    
  420. introduced the regression. Knowing the commit that caused the change in
    
  421. behavior helps identify if the change was intentional or if it was an
    
  422. inadvertent side-effect. Here's how you can determine this.
    
  423. 
    
  424. Begin by writing a regression test for Django's test suite for the issue. For
    
  425. example, we'll pretend we're debugging a regression in migrations. After you've
    
  426. written the test and confirmed that it fails on the latest main branch, put it
    
  427. in a separate file that you can run standalone. For our example, we'll pretend
    
  428. we created ``tests/migrations/test_regression.py``, which can be run with::
    
  429. 
    
  430.     $ ./runtests.py migrations.test_regression
    
  431. 
    
  432. Next, we mark the current point in history as being "bad" since the test fails::
    
  433. 
    
  434.     $ git bisect bad
    
  435.     You need to start by "git bisect start"
    
  436.     Do you want me to do it for you [Y/n]? y
    
  437. 
    
  438. Now, we need to find a point in git history before the regression was
    
  439. introduced (i.e. a point where the test passes). Use something like
    
  440. ``git checkout HEAD~100`` to check out an earlier revision (100 commits earlier,
    
  441. in this case). Check if the test fails. If so, mark that point as "bad"
    
  442. (``git bisect bad``), then check out an earlier revision and recheck. Once you
    
  443. find a revision where your test passes, mark it as "good"::
    
  444. 
    
  445.     $ git bisect good
    
  446.     Bisecting: X revisions left to test after this (roughly Y steps)
    
  447.     ...
    
  448. 
    
  449. Now we're ready for the fun part: using ``git bisect run`` to automate the rest
    
  450. of the process::
    
  451. 
    
  452.     $ git bisect run tests/runtests.py migrations.test_regression
    
  453. 
    
  454. You should see ``git bisect`` use a binary search to automatically checkout
    
  455. revisions between the good and bad commits until it finds the first "bad"
    
  456. commit where the test fails.
    
  457. 
    
  458. Now, report your results on the Trac ticket, and please include the regression
    
  459. test as an attachment. When someone writes a fix for the bug, they'll already
    
  460. have your test as a starting point.