You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It currently isn't retriggering when the MR goes from draft to ready. The main issue is in the is_draft_ready function which doesn't correctly handle the webhook data format coming from GitLab:
The problem is that the function is comparing string values 'true' and 'false', but in the webhook data, the values are booleans. In my PR, it converts string values to boolean if needed for compatibility with different GitLab versions and uses strict type comparison (is True and is False) to ensure correct behavior.
PR Type
Bug fix
Description
Fixes detection of draft-to-ready state in GitLab MRs
Adds compatibility for both boolean and string webhook values
Ensures strict type comparison for draft status changes
Changes walkthrough 📝
Relevant files
Bug fix
gitlab_webhook.py
Improve MR draft-to-ready detection for GitLab webhooks
pr_agent/servers/gitlab_webhook.py
Updates is_draft_ready to handle both boolean and string values
Converts string values to booleans for compatibility
Uses strict type comparison for draft status detection
The function now handles type conversion but doesn't have error handling for potential type conversion issues. If the string values aren't 'true' or 'false' but some other text, the conversion logic might not work as expected.
The current implementation only handles 'true' string value but GitLab may use different string representations for boolean values. Consider handling all possible string representations by checking if the lowercase string is in a set of truthy values.
# Convert to boolean if they're strings
if isinstance(previous, str):
- previous = previous.lower() == 'true'+ previous = previous.lower() in ('true', 'yes', '1', 'on')
if isinstance(current, str):
- current = current.lower() == 'true'+ current = current.lower() in ('true', 'yes', '1', 'on')
Apply / Chat
Suggestion importance[1-10]: 6
__
Why: The suggestion improves robustness by handling multiple string representations of boolean values beyond just 'true', which is a good practice for API integrations. While the current implementation works for GitLab's standard format, the enhancement provides better compatibility with potential variations.
Low
More
Author self-review: I have reviewed the PR code suggestions, and addressed the relevant ones.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
It currently isn't retriggering when the MR goes from draft to ready. The main issue is in the
is_draft_readyfunction which doesn't correctly handle the webhook data format coming from GitLab:{ "changes": { "draft": { "previous": true, "current": false }, }, }The problem is that the function is comparing string values 'true' and 'false', but in the webhook data, the values are booleans. In my PR, it converts string values to boolean if needed for compatibility with different GitLab versions and uses strict type comparison (is True and is False) to ensure correct behavior.
PR Type
Bug fix
Description
Fixes detection of draft-to-ready state in GitLab MRs
Adds compatibility for both boolean and string webhook values
Ensures strict type comparison for draft status changes
Changes walkthrough 📝
gitlab_webhook.py
Improve MR draft-to-ready detection for GitLab webhookspr_agent/servers/gitlab_webhook.py
is_draft_readyto handle both boolean and string values