oliver-zehentleitner / maity
hub: GET /avatars/public/{digest} for an agent checks that one agent, not the owner's whole listed_agents; picture rows read once
tsk-nstm4qq579wc Open
Audit round 3b (tsk-hgnbapyw7hnh), read at 80fef076. Kind: slow path on a public route.
What is wrong
routes/avatars.py:74-86->avatars.public(hub/src/maity_hub/avatars.py:427-447) ->is_public(avatars.py:396-421). For an agent,is_publicbuildspublic_people.listed_agents(conn, owner)(public_people.py:100-138) only to test whether this one agent is in it.listed_agentsrunspublic_agents.served(served check, profile hold read,membershipswithpublic_projects.servedper public project),latest_sessionandpublic_urlsfor every agent of the owner.- A public page shows many pictures, each its own GET, so cost grows with agents x projects per page view.
public()reads the picture rows twice for the same owner:_rowsatavatars.py:442, thenstored()calls_rowsagain (:308).- Not on tsk-m49x61yesmb6 (its item 3 covers only the people/contacts pages).
Proposal
- Factor the per-agent rule out of
listed_agentsintopublic_people.lists_agent(conn, owner, agent);listed_agentsloops over it,is_publiccalls it once, so the rule stays in one place. - Pass the
Picturealready read intostored().
Effort / risk: S. Low-medium (§6.10 public-picture rule); test_avatars covers the public cases.