Repository navigation
docs: describe the notification of subscribers - #84
Conversation
The API describes the call that notifies subscribers as the callback notification of POST /subscriptions, with the body NotificationRequest, and the usage guide shows it for listeners of their own instead of Pubgrade-Sidecar. An integration test checks that the call matches the description. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideAPIDefine the subscriber notification callback and its request schema in the OpenAPI specification, including response and timeout semantics.
DocumentationExplain how to receive subscriber notifications without the sidecar and point readers to the documented callback.
TestsCapture the notification content type and verify that the delivered request matches the callback's documented header and body schema.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #84 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 17
Lines 1471 1471
=========================================
Hits 1471 1471 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pubgrade/api/pubgrade.yaml" line_range="588" />
<code_context>
+ matches the subscription's `type` and `value`. Only the status
+ of the response counts, the body isn't read; a 2xx status
+ means `delivered`, any other status, a redirect or no
+ response within `endpoints.subscriptions.notification_timeout`
+ means `failed` (see the build's `notifications`). Redirects
+ aren't followed. A subscriber that takes longer answers at
</code_context>
<issue_to_address>
**Slow notifications misclassified in docs**
When connection establishment takes part of the timeout and the response arrives after the total time reaches `notification_timeout`, while each phase remains within its timeout, `requests.request` applies `notification_timeout` separately to connecting and waiting for response data, and `notify_all_subscriptions` allows up to twice that timeout plus a margin. A response arriving after the documented cutoff can still be `delivered`, so subscribers are given a stricter deadline than Pubgrade enforces.
Clarify that the timeout applies to connection and response waits separately, rather than implying one total deadline.
Also at `docs/usage.md:110`.
</issue_to_address>
### Comment 2
<location path="tests/integration/test_api.py" line_range="221-223" />
<code_context>
+ subscribe(api, user, repository["id"], subscriber.url)
+ publish(api, repository, "1")
+ [received] = subscriber.received
+ assert [parameter["name"] for parameter in callback["parameters"]] == [
+ "X-Access-Token"
+ ]
+ assert received["token"] == "subscriber-token"
+ assert set(received["body"]) == set(schema["properties"]) == set(schema["required"])
</code_context>
<issue_to_address>
**Callback spec drift passes conformance test**
When callback parameter metadata, the request-body schema reference, or the declared content type changes without a corresponding change to the notification request, `test_notification_matches_spec` checks parameter names and body values against `NotificationRequest`, but does not verify parameter `in`/`required`/`schema`, the callback’s schema reference, or the declared request-body content type against the received request. The test therefore passes when the documented callback does not match the notification request.
Compare the received notification’s parameter location and body against the callback’s declared parameter metadata, schema reference, and content type.
Also at `tests/integration/test_api.py:215`.
</issue_to_address>Linked issues
#10 Add callback to docs · 2 of 2 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Describe what the callback/notification to deployments looks like, including an overview. | ✅ Met | The Usage guide explains the PUT request, token header, body, response handling, and how a custom listener can process notifications. |
| 2 | Link to the corresponding OpenAPI specification. | ✅ Met | The Usage guide links to the API page, which links to the OpenAPI specification; the specification now documents the notification callback. |
Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: pubgrade/api/pubgrade.yaml:588, tests/integration/test_api.py:223
Review findings (Sourcery): the callback says that the timeout applies to connecting and again to the response, within twice that plus 5 seconds in all. The test also compares the header parameter, the content type and the schema reference of the callback with the call. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Describes what the notification to subscribers looks like, so that deployments can run listeners of their own instead of Pubgrade-Sidecar:
notificationonPOST /subscriptions(PUTtocallback_url, headerX-Access-Token, bodyNotificationRequestwithimage_nameandtag, 2xx =delivered, anything else =failed, no redirects followed).docs/usage.md: new subsection "Receiving notifications without the sidecar", with an example call, what a listener must do (check the token, answer withinnotification_timeout, work in the background), and links to the spec and to the sidecar's API as an example listener.docs/api.md: a pointer to the callback.No behaviour change.
Closes #10
Verification
pytest --cov: 597 passed, coverage 100%.ruff check,ruff format --check,mypy: clean.mkdocs build --strict: OK.Review
Light lane: docs and an additive OpenAPI description (callbacks are documentation only; connexion doesn't route them), plus one test. I reviewed the diff myself.
Declined review findings
None.
Open questions
None.
🤖 Generated with Claude Code