fix: address code review findings for inventory delta feature
- Fix remaining f-string SQL injection in process_inventory (same pattern as single-item endpoints: parameterized ANY(:ids) queries) - Add null guard for item_id in backend delta remove handler - Add response status logging for inventory service HTTP calls - Fix frontend ID fallback consistency in updateInventoryLive - Replace debug print() with logger.debug() - Add comment for Decal Slot_Decal magic number Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f145e6e131
commit
973c3722bc
3 changed files with 22 additions and 18 deletions
15
main.py
15
main.py
|
|
@ -1987,18 +1987,23 @@ async def ws_receive_snapshots(
|
|||
|
||||
if action == "remove":
|
||||
item_id = data.get("item_id")
|
||||
async with httpx.AsyncClient(timeout=10.0) as client:
|
||||
await client.delete(
|
||||
f"{INVENTORY_SERVICE_URL}/inventory/{char_name}/item/{item_id}"
|
||||
)
|
||||
if item_id is not None:
|
||||
async with httpx.AsyncClient(timeout=10.0) as client:
|
||||
resp = await client.delete(
|
||||
f"{INVENTORY_SERVICE_URL}/inventory/{char_name}/item/{item_id}"
|
||||
)
|
||||
if resp.status_code >= 400:
|
||||
logger.warning(f"Inventory service returned {resp.status_code} for delta remove item_id={item_id}")
|
||||
elif action in ("add", "update"):
|
||||
item = data.get("item")
|
||||
if item:
|
||||
async with httpx.AsyncClient(timeout=10.0) as client:
|
||||
await client.post(
|
||||
resp = await client.post(
|
||||
f"{INVENTORY_SERVICE_URL}/inventory/{char_name}/item",
|
||||
json=item
|
||||
)
|
||||
if resp.status_code >= 400:
|
||||
logger.warning(f"Inventory service returned {resp.status_code} for delta {action}")
|
||||
|
||||
# Broadcast delta to all browser clients
|
||||
await _broadcast_to_browser_clients(data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue