fix(investigate): check dismiss before npm_bump so dismiss_unaffected fires for npm - #118
Open
toufali wants to merge 2 commits into
Open
fix(investigate): check dismiss before npm_bump so dismiss_unaffected fires for npm#118toufali wants to merge 2 commits into
toufali wants to merge 2 commits into
Conversation
… fires for npm Fixes #112 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes the alert routing logic in scripts/post_alert_action.py so that, for unaffected alerts, the “dismiss if enabled (and severity allows)” path is evaluated before the recommended_action == "bump_pr" path—preventing npm alerts from always taking the npm_bump route and making investigate.dismiss_unaffected: true effective for npm (per #112).
Changes:
- Reordered the “dismiss unaffected (low/medium)” check to run before the
bump_pr/npm_bumprouting logic. - Added a regression test ensuring unaffected npm alerts are dismissed (not routed to
npm_bump) when dismissal is enabled.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/post_alert_action.py | Moves the dismiss-unaffected check earlier so it takes precedence over the bump path (including npm). |
| tests/scripts/test_post_alert_action.py | Adds a regression test to ensure dismissal wins over npm_bump for unaffected npm alerts. |
Comment on lines
+473
to
+480
| elif dismiss_enabled and severity.lower() not in DISMISS_BLOCKED_SEVERITIES: | ||
| # Checked before bump_pr: dismissing is the intended outcome for an | ||
| # unaffected low/medium alert, and it must take precedence over the | ||
| # npm bump path (which is npm-only and never fired dismiss for npm | ||
| # alerts — see #112). | ||
| print(" Unaffected + dismiss enabled (low/medium). Dismissing alert.") | ||
| dismiss_alert(repo, alert_number, reason, dry_run) | ||
| action = "dismissed" |
| outputs = open(output_file).read() | ||
| assert "action=dismissed" in outputs | ||
| assert "action=npm_bump" not in outputs | ||
|
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #112.
For an unaffected alert, the
recommended == "bump_pr"branch (→npm_bump) was evaluated before thedismiss_enabledbranch, so on npm repos unaffected alerts always routed tonpm_bumpandinvestigate.dismiss_unaffected: truenever took effect.This moves the dismiss check (unaffected + low/medium) above the bump branch in
post_alert_action.py, so unaffected low/medium alerts are dismissed as intended. Critical/high are unchanged (still blocked from auto-dismiss).🤖 Generated with Claude Code