Skip to content

fix: use False as default for draft field in pull request event check#2273

Open
wishhyt wants to merge 1 commit intoqodo-ai:mainfrom
wishhyt:fix/github-draft-default-value
Open

fix: use False as default for draft field in pull request event check#2273
wishhyt wants to merge 1 commit intoqodo-ai:mainfrom
wishhyt:fix/github-draft-default-value

Conversation

@wishhyt
Copy link
Copy Markdown

@wishhyt wishhyt commented Mar 18, 2026

Summary

  • pull_request.get("draft", True) defaults to True when the draft field is absent from the webhook payload
  • This means PRs without an explicit draft field are treated as drafts and silently skipped
  • The safe default should be False (assume not a draft), otherwise legitimate PRs may be ignored without any log indication

Changes

pr_agent/servers/github_app.py: Changed default value from True to False

Test plan

  • Verify that PRs without a draft field in the webhook payload are processed normally
  • Verify that actual draft PRs (with "draft": true) are still correctly skipped

`pull_request.get("draft", True)` incorrectly defaults to True when
the draft field is absent from the webhook payload, causing non-draft
PRs to be silently skipped. Default to False so PRs without an
explicit draft field are processed normally.

Made-with: Cursor
@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Fix draft field default value in GitHub pull request event validation

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Changed draft field default from True to False in pull request validation
• Prevents legitimate PRs without explicit draft field from being silently skipped
• Ensures PRs are processed normally when draft status is absent from webhook payload
Diagram
flowchart LR
  A["Webhook payload without draft field"] -->|Previously defaulted to True| B["PR silently skipped"]
  A -->|Now defaults to False| C["PR processed normally"]
  D["Webhook with draft=true"] -->|Still skipped| E["Draft PR ignored"]
Loading

Grey Divider

File Changes

1. pr_agent/servers/github_app.py 🐞 Bug fix +1/-1

Fix draft field default value in PR validation

• Changed pull_request.get("draft", True) to pull_request.get("draft", False) in
 _check_pull_request_event method
• Fixes logic where PRs without explicit draft field were incorrectly treated as drafts
• Ensures non-draft PRs are processed even when draft field is missing from webhook payload

pr_agent/servers/github_app.py


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

qodo-free-for-open-source-projects bot commented Mar 18, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Missing test for draft-default 📘 Rule violation ⛯ Reliability
Description
The PR changes webhook behavior by treating missing draft as False, but no pytest coverage is
added/updated to lock this behavior in. This risks regression where PRs without an explicit draft
field could be silently skipped again.
Code

pr_agent/servers/github_app.py[387]

+    if pull_request.get("draft", False) or pull_request.get("state") != "open":
Evidence
Compliance requires behavior changes to be validated with pytest coverage (ID 12). The changed
condition now defaults draft to False, but existing unit coverage builds webhook payloads with
an explicit draft field and does not test the missing-field case, leaving the new behavior
unverified.

AGENTS.md
pr_agent/servers/github_app.py[382-390]
tests/unittest/test_add_docs_trigger.py[62-76]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The webhook validation now defaults missing `pull_request.draft` to `False`, but there is no pytest coverage ensuring PR events without a `draft` field are processed.

## Issue Context
GitHub webhook payloads may omit the `draft` field. Without a test, this behavior can regress and silently skip legitimate PRs.

## Fix Focus Areas
- tests/unittest/test_add_docs_trigger.py[11-75]
- pr_agent/servers/github_app.py[387-388]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

return invalid_result
log_context["api_url"] = api_url
if pull_request.get("draft", True) or pull_request.get("state") != "open":
if pull_request.get("draft", False) or pull_request.get("state") != "open":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

1. Missing test for draft-default 📘 Rule violation ⛯ Reliability

The PR changes webhook behavior by treating missing draft as False, but no pytest coverage is
added/updated to lock this behavior in. This risks regression where PRs without an explicit draft
field could be silently skipped again.
Agent Prompt
## Issue description
The webhook validation now defaults missing `pull_request.draft` to `False`, but there is no pytest coverage ensuring PR events without a `draft` field are processed.

## Issue Context
GitHub webhook payloads may omit the `draft` field. Without a test, this behavior can regress and silently skip legitimate PRs.

## Fix Focus Areas
- tests/unittest/test_add_docs_trigger.py[11-75]
- pr_agent/servers/github_app.py[387-388]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant