Skip to content

feat: use first_location_detected to eliminate per-alert locations API calls#70

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/enhancement-simplify-ghsp-implementation
Draft

feat: use first_location_detected to eliminate per-alert locations API calls#70
Copilot wants to merge 3 commits intomainfrom
copilot/enhancement-simplify-ghsp-implementation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

  • Identify that using first_location_detected unconditionally is a correctness regression: when has_more_locations is true, only the first (globally-oldest) location is checked, missing PR matches in later locations
  • Fix action.ps1: only use first_location_detected when has_more_locations is falsy; otherwise call the locations API
  • Fix action.py: same fix for the match loop; also refactor to collect ALL matching locations per alert (not just the first match), consistent with PowerShell behavior
  • Update Python output loop to iterate all matched locations per alert (consistent with PS)
  • All 38 tests pass

Copilot AI requested review from Copilot and removed request for Copilot April 13, 2026 17:44
Comment thread action.py Fixed
Comment thread action.py Fixed
Copilot AI changed the title [WIP] Enhance GHSP API integration for first location detected feat: use first_location_detected to eliminate per-alert locations API calls Apr 13, 2026
Copilot AI requested a review from felickz April 13, 2026 17:47
Copilot AI requested review from Copilot and removed request for Copilot April 13, 2026 21:29
Comment thread action.py
# Determine which locations to check
if alert.get('first_location_detected') and not alert.get('has_more_locations'):
# Single location: use first_location_detected directly, no locations API call needed
logging.debug(f"Using first_location_detected for alert {alert['number']} (single location, no API call needed)")
Comment thread action.py
# consistent with the PowerShell runtime behavior.
matched_locs = alert_matched_locations.get(alert['number'], [])
if not matched_locs:
logging.warning(f"No matched locations found for alert #{alert['number']}; skipping output.")
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.

Enhancement: GHSP API now returns the first_location_detected in the alert - can we simplify implementation?

3 participants