You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missing Location header on a 2xx create raises a bare KeyError #44
res.ok is true for any 2xx. A server that answers 200 OK or 204 No Content without a Location header — spec-legal, and what some proxies produce after stripping or rewriting headers — makes res.headers['Location'] raise a bare KeyError: 'Location'. The traceback points at a dict lookup, giving no hint that the POST actually succeeded and only the id is missing.
Reproduce
Point any of the above at a server (or proxy) that returns 2xx without Location. In a unit test:
Treat a missing Location as its own failure mode, with a message that says the POST succeeded but the id couldn't be recovered:
location=res.headers.get('Location')
iflocationisNone:
raiseException(
f'System {self.label!r} POST returned HTTP {res.status_code} but no 'f'Location header; cannot determine the server-assigned id.'
)
Same shape at all five sites. Since this is the fifth "the POST path needs a consistent error contract" item, the five bare raise Exception(...) calls are probably worth promoting to a typed exception at the same time.
Activity