fix: AttributeError when DRAFT_PR_TRACKING is enabled#570
Conversation
Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
DRAFT_PR_TRACKING is not working when set to true|
@copilot can you fix the failing github actions on this pull request? |
Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
I've fixed the failing GitHub Actions. The issues were:
All tests now pass (115/115) and linting is clean. The GitHub Actions should now pass successfully. Commit: 80d8649 |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an AttributeError that occurs when the DRAFT_PR_TRACKING feature is enabled, where the measure_time_in_draft function was incorrectly calling issue.events() instead of issue.issue.events() on search result objects.
- Updates the function to use the correct nested attribute access pattern
- Adds comprehensive test coverage for the bug scenario
- Aligns with the established pattern used throughout the codebase
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| time_in_draft.py | Fixed the AttributeError by changing issue.events() to issue.issue.events() |
| test_time_in_draft.py | Updated all test mocks to use the correct nested structure and added a regression test |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
|
@zkoppert do we want to add release label on this one? |
When
DRAFT_PR_TRACKINGis set totrue, themeasure_time_in_draftfunction throws anAttributeError: eventsbecause it attempts to callissue.events()directly on a search result object that doesn't have anevents()method.The issue occurs because:
get_per_issue_metricspasses issue search result objects tomeasure_time_in_draftissue.issue.events()issue.events()instead of following the established patternBefore:
After:
This change aligns with the pattern used throughout the codebase in functions like
get_label_events()andget_time_to_ready_for_review()which correctly useissue.issue.events().The fix is minimal and surgical - only one line changed in the core function, with corresponding test updates to match the real-world usage pattern.
Fixes #567.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.