test(feed): cover malformed-cursor 400 + from-None on the re-raise

Second-round /code-review high follow-ups:

- test_feed_cursor.py: GET /api/feed?cursor=<garbage> must return HTTP 400
  (not 500) — locks the cursor-error path the refactor split across modules
  (feedquery.decode_cursor raises ValueError, get_feed translates to 400).
  Plus a no-cursor 200 sanity check. DB lane.
- get_feed: `raise HTTPException(...) from None` so the expected bad-input
  ValueError isn't chained as __context__.

DB-lane suite 289 passed / 2 skipped; ruff clean.
This commit is contained in:
2026-08-17 18:46:48 +02:00
parent 2ab188d873
commit c0cda545e0
2 changed files with 47 additions and 1 deletions
+2 -1
View File
@@ -104,7 +104,8 @@ def get_feed(
try:
vals, cursor_id = decode_cursor(keys, cursor)
except ValueError:
raise HTTPException(status_code=400, detail="Invalid feed cursor")
# `from None`: the ValueError is an expected bad-input signal, not an error to chain.
raise HTTPException(status_code=400, detail="Invalid feed cursor") from None
for k, v in zip(keys, vals):
k["value"] = v
query = query.where(keyset_predicate(keys, cursor_id))