Private
Public Access
Fix WNS push 400s and improve push failure logging (#56)
WNS (Windows/Edge push) has required an X-WNS-Cache-Policy header since April 2024; the production venv was likely still on the old pywebpush 2.0.x installed when the app was first deployed, which predates the library's fix. Floored the dependency at 2.4.0 (current latest) so the next deploy picks it up. Also logs response body and headers on any non-410/404 push failure, not just body text -- WNS's own 400s carry their actual reason in a header, which the old body-only logging would still have missed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -95,4 +95,17 @@ async def send_push_to_user(db: AsyncSession, user_id: uuid.UUID, payload: dict)
|
||||
)
|
||||
await db.commit()
|
||||
else:
|
||||
logger.warning("Push delivery failed for %s: %s", subscription.id, exc)
|
||||
# #56: WNS's own 400s carry the actual reason in a response
|
||||
# *header* ("Ttl value conflicts with X-WNS-Cache-Policy"),
|
||||
# not the body -- pywebpush's own exception message only
|
||||
# ever surfaces the body, so that specific bug still would
|
||||
# have needed a full journalctl+DB-dump investigation to
|
||||
# diagnose even with a body-only log line. Logging headers
|
||||
# too is the difference between "something is broken" and
|
||||
# this log line alone being enough next time, for any push
|
||||
# provider's failure, not just WNS's.
|
||||
response = exc.response
|
||||
detail = ""
|
||||
if response is not None:
|
||||
detail = f" | response: {response.text!r} | headers: {dict(response.headers)!r}"
|
||||
logger.warning("Push delivery failed for %s: %s%s", subscription.id, exc, detail)
|
||||
|
||||
Reference in New Issue
Block a user