From 2be3d223069809d45e5feddb72846ae0e8575edd Mon Sep 17 00:00:00 2001 From: Maddox Date: Fri, 29 May 2026 20:18:35 -0400 Subject: [PATCH] v0.6.3: encode-safe URLs to Seerr (fixes #4) Queries containing apostrophes/parens/etc were 400ing on Seerr's strict ajv validator. The SeerrClient _qs() helper percent-encodes the value correctly, but aiohttp parses the URL string through yarl.URL(), which normalizes %27 (and other sub-delims) back to the literal character in the query component. The literal ' then trips Seerr's "must be url encoded" check. Fix: pass yarl.URL(url, encoded=True) to bypass yarl's re-normalization so the RFC 3986 form built by _qs reaches Seerr unchanged. Reproduced + verified against deployed Seerr v3.2.0 with queries including "rocky's revenge", "what's up, doc?", "8 1/2". Closes #4 --- maubot.yaml | 2 +- media_bot/clients/seerr.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/maubot.yaml b/maubot.yaml index 18fded8..71e7579 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.3.1 id: com.3ddbrewery.media -version: 0.6.2 +version: 0.6.3 license: MIT modules: - media_bot diff --git a/media_bot/clients/seerr.py b/media_bot/clients/seerr.py index aab75de..3afe358 100644 --- a/media_bot/clients/seerr.py +++ b/media_bot/clients/seerr.py @@ -13,6 +13,7 @@ from typing import Optional from urllib.parse import quote import aiohttp +import yarl class SeerrError(RuntimeError): @@ -34,7 +35,10 @@ class SeerrClient: url = f"{self.base}{path}" if params: url += "?" + _qs(params) - async with self.session.get(url, headers=self.headers) as r: + # yarl decodes "safe" sub-delims like %27 back to literal ' in the query, + # which Seerr's strict ajv validator then rejects. encoded=True keeps the + # RFC 3986 encoding we built with _qs intact on the wire. + async with self.session.get(yarl.URL(url, encoded=True), headers=self.headers) as r: if r.status >= 400: raise SeerrError(f"GET {path} → {r.status}: {(await r.text())[:200]}") return await r.json()