Skip to content

docs: describe the notification of subscribers - #84

Merged
uniqueg merged 2 commits into
devfrom
docs/notification-format
Nov 7, 2026
Merged

uniqueg merged 2 commits into
devfrom
docs/notification-format

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Describes what the notification to subscribers looks like, so that deployments can run listeners of their own instead of Pubgrade-Sidecar:

  • OpenAPI: callback notification on POST /subscriptions (PUT to callback_url, header X-Access-Token, body NotificationRequest with image_name and tag, 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 within notification_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.
  • Integration test: the call a subscriber receives matches the callback's header and body schema in the spec, so the description can't drift from the code.

No behaviour change.

Closes #10

Verification

  • New test fails without the spec change and passes with it.
  • pytest --cov: 597 passed, coverage 100%.
  • ruff check, ruff format --check, mypy: clean. mkdocs build --strict: OK.
  • CI on the PR: all checks passed on 8918efc; Sourcery's two findings (exact timeouts, stricter test) fixed in 7c9e982.

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

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]>
@sourcery-ai

sourcery-ai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Define the subscriber notification callback and its request schema in the OpenAPI specification, including response and timeout semantics.

  • pubgrade/api/pubgrade.yaml L578-617, L1107-1123

Documentation

Explain how to receive subscriber notifications without the sidecar and point readers to the documented callback.

  • docs/api.md L48-52
  • docs/usage.md L94-118

Tests

Capture the notification content type and verify that the delivered request matches the callback's documented header and body schema.

  • tests/integration/conftest.py L144
  • tests/integration/test_api.py L10-12, L189, L203-241

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 Pubgrade | 🛠️ Build #35720452 | 📁 Comparing 7c9e982 against latest (f5a3d70)

  🔍 Preview build  

2 files changed
± api/index.html
± usage/index.html

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f5a3d70) to head (7c9e982).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 7, 2026 14:54
@uniqueg
uniqueg requested a review from akash2237778 as a code owner November 7, 2026 14:54

@sourcery-ai sourcery-ai 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.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread pubgrade/api/pubgrade.yaml Resolved
Comment thread tests/integration/test_api.py Resolved
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]>

@sourcery-ai sourcery-ai 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.

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit 169b82c into dev Nov 7, 2026
36 of 46 checks passed
@uniqueg
uniqueg deleted the docs/notification-format branch November 7, 2026 15:07
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.

Add callback to docs

1 participant