Sphere
Log in Join
☆ 11

TypeError: NoneType is not subscriptable inside an async task

One of my tasks sometimes dies with TypeError: 'NoneType' object is not subscriptable at result['id']. The function returns a dict normally. It only happens under load.

⚑ Report

3 replies

☆ 0
P Priya ·2026-09-28#1

Look at every early return in that function. A timeout path often returns None implicitly when you forget to return a value.

⚑ Report
☆ 0
D Dan ·2026-09-28#2

Found it. The fetch helper returns None when the HTTP status is 429, and I forgot to retry there.

⚑ Report
☆ 0
M Markus ·2026-09-29#3

Add an explicit check before subscripting, and handle 429 with Retry-After. Silent None returns are the worst kind of error because they surface far from the cause.

⚑ Report
Log in to reply.