Skip to content

fix: AttributeError when DRAFT_PR_TRACKING is enabled #570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 16, 2025
Merged

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 15, 2025

When DRAFT_PR_TRACKING is set to true, the measure_time_in_draft function throws an AttributeError: events because it attempts to call issue.events() directly on a search result object that doesn't have an events() method.

The issue occurs because:

  • get_per_issue_metrics passes issue search result objects to measure_time_in_draft
  • These objects have a nested structure where events are accessed via issue.issue.events()
  • The function was incorrectly calling issue.events() instead of following the established pattern

Before:

events = issue.events()  # ❌ AttributeError: events

After:

events = issue.issue.events()  # ✅ Works correctly

This change aligns with the pattern used throughout the codebase in functions like get_label_events() and get_time_to_ready_for_review() which correctly use issue.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.

Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] DRAFT_PR_TRACKING is not working when set to true Fix AttributeError when DRAFT_PR_TRACKING is enabled Aug 15, 2025
@Copilot Copilot AI requested a review from zkoppert August 15, 2025 17:56
Copilot finished work on behalf of zkoppert August 15, 2025 17:56
@github-actions github-actions bot added the fix label Aug 15, 2025
@zkoppert zkoppert changed the title Fix AttributeError when DRAFT_PR_TRACKING is enabled fix: AttributeError when DRAFT_PR_TRACKING is enabled Aug 15, 2025
@zkoppert
Copy link
Member

@copilot can you fix the failing github actions on this pull request?

Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Aug 15, 2025

@copilot can you fix the failing github actions on this pull request?

I've fixed the failing GitHub Actions. The issues were:

  1. AttributeError fix: Changed issue.events() to issue.issue.events() in time_in_draft.py to properly access events through the nested issue structure
  2. Test coverage: Updated all tests to use the correct mock structure and added a specific test case that reproduces the original AttributeError scenario
  3. Linting fixes: Cleaned up trailing whitespace issues

All tests now pass (115/115) and linting is clean. The GitHub Actions should now pass successfully.

Commit: 80d8649

Copilot finished work on behalf of zkoppert August 15, 2025 22:10
@zkoppert zkoppert marked this pull request as ready for review August 15, 2025 22:15
@zkoppert zkoppert requested a review from a team as a code owner August 15, 2025 22:15
@Copilot Copilot AI review requested due to automatic review settings August 15, 2025 22:15
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jmeridth
Copy link
Member

@zkoppert do we want to add release label on this one?

@zkoppert zkoppert merged commit 2212538 into main Aug 16, 2025
32 checks passed
@zkoppert zkoppert deleted the copilot/fix-567 branch August 16, 2025 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DRAFT_PR_TRACKING is not working when set to true
3 participants