Skip to content

feat(pagerduty): validate integration + add 9 tools for deeper API coverage#5446

Merged
waleedlatif1 merged 5 commits into
stagingfrom
validate/pagerduty-integration
Jul 6, 2026
Merged

feat(pagerduty): validate integration + add 9 tools for deeper API coverage#5446
waleedlatif1 merged 5 commits into
stagingfrom
validate/pagerduty-integration

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Ran a full /validate-integration audit of PagerDuty against the official REST API v2 + Events API v2 OpenAPI specs
  • Fixed a critical bug: list tools defaulted total to 0 instead of null (PagerDuty only returns total when explicitly requested)
  • Added missing pagination offset support across all list tools
  • Added missing fields: incidentKey/incident_key on create, resolution on update/resolve, urgencies[] filter on list, triggered status option
  • Added 9 new tools confirmed against the real API spec: get_incident, get_service, list_escalation_policies, list_incident_alerts, list_schedules, list_users, merge_incidents, snooze_incident (REST API v2), and send_event (Events API v2 — trigger/acknowledge/resolve via routing key)
  • Added 2 new BlockMeta skills grounded in documented PagerDuty workflows
  • Verified 100% backwards compatible — no existing param/output field removed or renamed; all changes are additive or spec-correctness fixes

Type of Change

  • Bug fix
  • New feature

Testing

  • Verified every field against PagerDuty's official OpenAPI v3 REST + Events v2 specs (github.com/PagerDuty/api-schema)
  • Diffed every modified file against origin/staging to confirm no regressions
  • bun run lint clean, bun run type-check clean (sim package), vitest block/tool tests pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…verage

- fix list tools' total field to null-default (matches PagerDuty spec, was wrong 0 default)
- add pagination offset across all list tools
- add incidentKey, resolution, urgencies, triggered status support
- add get_incident, get_service, list_escalation_policies, list_incident_alerts,
  list_schedules, list_users, merge_incidents, snooze_incident tools (REST API v2)
- add send_event tool (Events API v2) for trigger/acknowledge/resolve via routing key
- add 2 new BlockMeta skills grounded in documented PagerDuty workflows
@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 6, 2026 10:38pm

Request Review

@cursor

cursor Bot commented Jul 6, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
New write paths (merge, snooze, Events API paging) can change real on-call state; total changing from 0 to null may affect workflows that assumed a number.

Overview
Expands the PagerDuty block and tool layer with nine new operations—get incident/service, list alerts, escalation policies, schedules, users, snooze, merge, and Send Event (Events API v2 via integration key instead of REST API key)—plus UI wiring, inputs/outputs, and two new block skills.

Existing tools are tightened to the official API: list endpoints now expose offset, optional urgencies on list incidents, incidentKey on create, resolution and triggered on update, and list responses use total: null when PagerDuty omits it (fixing the previous default of 0). Send Event uses a separate routingKey credential path in the block.

Registry registers all new pagerduty_* tools alongside the prior six.

Reviewed by Cursor Bugbot for commit ab9a335. Configure here.

Comment thread apps/sim/tools/pagerduty/merge_incidents.ts Outdated
Comment thread apps/sim/tools/pagerduty/send_event.ts
Comment thread apps/sim/tools/pagerduty/snooze_incident.ts Outdated
@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR significantly expands the PagerDuty integration by adding 9 new tools (get_incident, get_service, list_escalation_policies, list_incident_alerts, list_schedules, list_users, merge_incidents, snooze_incident, send_event) and fixing a spec correctness bug where list tools returned total: 0 instead of total: null when PagerDuty omits the field.

  • Bug fix: total now correctly defaults to null across list_incidents, list_services, and list_oncalls, matching PagerDuty's actual pagination behavior where total is only populated when explicitly requested.
  • New tools: All 9 tools are implemented with consistent patterns — proper error guards (snooze validates duration range, send_event validates required trigger fields, merge validates non-empty source IDs), correct PagerDuty API header conventions, and type-safe response mapping.
  • Block config: New operations and fields are properly wired in pagerduty.ts including the send_event flow which uses a separate routingKey credential and hides/shows the REST apiKey field based on operation.

Confidence Score: 5/5

Safe to merge; all changes are additive, backwards compatible, and the three previously flagged runtime issues have been correctly addressed.

All 9 new tools follow established patterns with correct PagerDuty API headers, explicit runtime guards before building request bodies, and null-safe response mapping. The total-defaulting bug fix is spec-correct and non-breaking. The one remaining point (updateResolution field visibility vs. tool guard) results in a clear error message rather than silent bad data.

apps/sim/blocks/blocks/pagerduty.ts — the updateResolution field condition could be tightened to match the tool's own guard, preventing a confusing runtime error when a user fills the field alongside a non-resolve status change.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/pagerduty.ts Adds 9 new operation entries, credentials switching (apiKey vs routingKey), new block fields, and block-level params mapping. The updateResolution field condition doesn't match the tool guard, potentially showing the field for non-resolve update operations while the tool would throw at runtime.
apps/sim/tools/pagerduty/send_event.ts New Events API v2 tool; correctly validates required trigger fields (summary/source/severity) and required dedupKey for acknowledge/resolve before building the payload.
apps/sim/tools/pagerduty/snooze_incident.ts New snooze tool with correct duration range validation (1–604800 seconds) and integer check via Number.isInteger.
apps/sim/tools/pagerduty/merge_incidents.ts New merge tool with comma-split parsing and empty-ID guard; correct PUT endpoint and incident_reference payload shape.
apps/sim/tools/pagerduty/update_incident.ts Adds resolution and triggered-status support; the resolution guard correctly prevents setting the field without status:resolved in the same request.
apps/sim/tools/pagerduty/list_incidents.ts Adds urgencies filter, offset pagination, and fixes total null bug; consistent with other list tools.
apps/sim/tools/pagerduty/get_incident.ts New single-incident GET tool; correctly maps assignee, escalation policy, incidentKey, and resolvedAt fields.
apps/sim/tools/pagerduty/types.ts Adds types for all 9 new tools; total fields correctly typed as number
apps/sim/tools/registry.ts All 9 new tool IDs correctly imported and registered under their canonical pagerduty_* keys.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
  participant UI as Block UI
  participant Block as pagerduty.ts (Block Config)
  participant RESTAPI as PagerDuty REST API v2
  participant EventsAPI as PagerDuty Events API v2

  Note over UI,Block: REST operations (list/get/create/update/snooze/merge)
  UI->>Block: "operation != send_event, apiKey + params"
  Block->>RESTAPI: "Authorization: Token token=apiKey"
  Block->>RESTAPI: From: fromEmail (write ops only)
  RESTAPI-->>Block: incident/service/user/policy/schedule data
  Block-->>UI: Structured typed output

  Note over UI,Block: send_event operation
  UI->>Block: "operation = send_event, routingKey + eventAction"
  Block->>EventsAPI: POST /v2/enqueue routing_key + event_action + payload
  Note over Block,EventsAPI: trigger requires summary+source+severity
  Note over Block,EventsAPI: acknowledge/resolve require dedupKey
  EventsAPI-->>Block: status + message + dedup_key
  Block-->>UI: status + message + dedupKey
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
  participant UI as Block UI
  participant Block as pagerduty.ts (Block Config)
  participant RESTAPI as PagerDuty REST API v2
  participant EventsAPI as PagerDuty Events API v2

  Note over UI,Block: REST operations (list/get/create/update/snooze/merge)
  UI->>Block: "operation != send_event, apiKey + params"
  Block->>RESTAPI: "Authorization: Token token=apiKey"
  Block->>RESTAPI: From: fromEmail (write ops only)
  RESTAPI-->>Block: incident/service/user/policy/schedule data
  Block-->>UI: Structured typed output

  Note over UI,Block: send_event operation
  UI->>Block: "operation = send_event, routingKey + eventAction"
  Block->>EventsAPI: POST /v2/enqueue routing_key + event_action + payload
  Note over Block,EventsAPI: trigger requires summary+source+severity
  Note over Block,EventsAPI: acknowledge/resolve require dedupKey
  EventsAPI-->>Block: status + message + dedup_key
  Block-->>UI: status + message + dedupKey
Loading

Reviews (5): Last reviewed commit: "docs(pagerduty): mention triggered as a ..." | Re-trigger Greptile

Comment thread apps/sim/blocks/blocks/pagerduty.ts
Comment thread apps/sim/tools/pagerduty/snooze_incident.ts Outdated
Comment thread apps/sim/tools/pagerduty/send_event.ts
…lidation

- match required condition to visibility condition for eventSummary/eventSource (trigger-only)
- validate trigger payload has summary/source/severity before sending, throw descriptive error
- validate snooze duration is finite and within PagerDuty's 1-604800 range
- drop empty segments when splitting merge source incident IDs
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/tools/pagerduty/merge_incidents.ts
Comment thread apps/sim/tools/pagerduty/send_event.ts
Comment thread apps/sim/tools/pagerduty/snooze_incident.ts
… integer snooze duration

- merge_incidents: throw if source_incidents ends up empty after filtering blanks
- send_event: require dedupKey for acknowledge/resolve to match block's required condition
- snooze_incident: require an integer duration, not just a finite number
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/tools/pagerduty/update_incident.ts Outdated
PagerDuty only accepts an incident's resolution field when status is
being set to resolved in the same request; sending it otherwise gets
rejected by the API with an opaque error.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8d6d341. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ab9a335. Configure here.

@waleedlatif1 waleedlatif1 merged commit be6f693 into staging Jul 6, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the validate/pagerduty-integration branch July 6, 2026 22:50
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