Skip to content

test(ci): assert status codes and response shape for the remaining /webhook/* routes - #176

Merged
OkiriGabriel merged 1 commit into
open-devops-agent:mainfrom
OpeyemiAdeniji:ci/assert-remaining-webhooks
Nov 21, 2026
Merged

OkiriGabriel merged 1 commit into
open-devops-agent:mainfrom
OpeyemiAdeniji:ci/assert-remaining-webhooks

Conversation

@OpeyemiAdeniji

@OpeyemiAdeniji OpeyemiAdeniji commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow-up to #107, which asserted responses for /webhook/manual only. This extends the integration job to the other /webhook/* routes: github, gitlab, bitbucket, alertmanager and grafana.

A new "Define Webhook Test Helpers" step writes two small shell functions to $RUNNER_TEMP/webhook_helpers.sh: post (sends the request, captures status and body) and expect (asserts the status code and a jq condition, and on mismatch prints both and exits non-zero). Each route step sources it, so every check is two lines.

What each route asserts:

  • github: failed workflow_run → 200 queued, type == "cicd"; opened pull_request → 200 queued, type == "code_review"; draft PR → 200 ignored, reason == "draft_pr"; push → 200 ignored, event == "push"; invalid JSON → 400 JSON object required
  • gitlab: failed pipeline → 200 queued, cicd; opened MR → 200 queued, code_review; successful pipeline → 200 ignored; invalid JSON → 400
  • bitbucket: pullrequest:created → 200 queued, code_review; repo:push → 200 ignored, reason == "unsupported_event"; invalid JSON → 400
  • alertmanager: firing alert → 200 queued with one incident_ids entry; the same alert again → 200 duplicate with duplicate_of equal to the first incident id ([BUG] Repeated Alertmanager/Grafana notifications create duplicate incidents and can re-apply fixes #124 dedup); invalid JSON → 400
  • grafana: firing alert → 200 queued with one incident_ids entry; invalid JSON → 400

"Queued" means status == "queued" plus a non-empty string incident_id (or a one-element incident_ids for the alert routes).

Part of #18 (this completes the /webhook/* assertion item; Black, Safety/Bandit and coverage are still open there)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • New platform/collector support

CI configuration change (none of the listed types fit).

Platform/Component

  • Core Agent
  • Kubernetes
  • CI/CD (specify: GitHub Actions workflow, integration-test job)
  • Cloud Provider
  • ArgoCD
  • Docker
  • API Server
  • Tools/Executor
  • Documentation
  • Tests

Testing

  • Unit tests added/updated

  • Integration tests pass

  • Manual testing performed

  • Tested with dummy data

  • Tested in production-like environment

  • Sent every payload used in the new steps to the real routes in-process with FastAPI's TestClient, without the with block so the lifespan and queue worker never ran; STORAGE_PROVIDER=memory (also the default the CI server uses) and WEBHOOK_SECRET unset. All responses matched the assertions above, including the alertmanager duplicate.

  • Parsed the workflow with yaml.safe_load, ran the helper step for real to generate the helpers file, and ran bash -n on each new run: script.

  • jq isn't installed on my machine, so locally the jq filters were checked by hand against the captured responses.

  • CI result on this PR: the Integration Test job passed, and its log shows all 17 new assertions (✓ ... lines) passing against the live server, including the alertmanager duplicate check. The other checks pass as well.

  • Did not re-run the full test suite locally: this is a workflow-only change.

Test Configuration

OS: Windows (Git Bash)
Python Version: 3.12 (CI integration job uses 3.10)
Kubernetes Version: N/A
Cloud Provider: N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas (N/A)
  • I have made corresponding changes to the documentation (N/A)
  • My changes generate no new warnings (N/A: workflow-only change)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (not re-run; workflow-only change)
  • Any dependent changes have been merged and published

Screenshots (if applicable)

N/A

Breaking Changes

None to the application. In CI, changes to the status codes or response shape of these routes will now fail the integration job. As with #107, the fail-closed webhook work in #64 will need to update these steps (e.g. send a signature) if it lands.

Additional Notes

  • While probing I noticed that /webhook/alertmanager with only resolved alerts returns {"status": "queued", "incident_ids": []}, which reads as queued when nothing was. I deliberately did not assert that case so this PR doesn't lock it in; happy to open a separate issue/PR if you agree it should be something like "ignored".
  • The manual webhook and Audit steps are unchanged.

Reviewer Checklist

  • Code quality is acceptable
  • Tests are comprehensive
  • Documentation is updated
  • No security concerns
  • Performance impact is acceptable

Extend the integration job's response checks from /webhook/manual to
github, gitlab, bitbucket, alertmanager and grafana. Each route covers
a queued event, an ignored event (or alert dedup for alertmanager)
and invalid JSON -> 400. A shared helper step keeps each check short
and prints the status and body on failure.

Part of open-devops-agent#18

@OkiriGabriel OkiriGabriel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @OpeyemiAdeniji, this covers every /webhook/* route, including the negative paths (draft PR, unsupported events, invalid JSON) and the Alertmanager dedupe from #147 (the second delivery must be duplicate_of the first incident). The post/expect helpers keep each check to two lines. When step 3 (fail closed) lands, the server step will need WEBHOOK_SECRET and these requests will need signing, as you planned in step 2. Approving.

@OkiriGabriel
OkiriGabriel merged commit c962843 into open-devops-agent:main Nov 21, 2026
14 checks passed
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.

2 participants