Skip to content

fix(pixel-agent-teams): guard get result in list to tolerate unreadable history files - #5944

Open
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/pixel-agent-teams-list-unreadable
Open

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/pixel-agent-teams-list-unreadable

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/extensions/services/dashboard-api/pixel_agent_teams.py, TeamStore.list(owner, chat) scans the agent history directory for files matching {owner}-*.json and processes each file with row = self.get(owner, path.stem[65:]), followed immediately by accessing if row["chat_id"] == chat:. If a file in the directory is corrupted, partially written, permissions-restricted, or returns None from self.get(), accessing row["chat_id"] raises an unhandled TypeError: 'NoneType' object is not subscriptable or KeyError. This causes the entire agent team listing endpoint to crash for that user instead of gracefully skipping unreadable entries.

This change wraps self.get() in a local exception handler and guards the membership test with if isinstance(row, dict) and row.get("chat_id") == chat:. It also uses x.get("created", 0) during sorting so that missing creation timestamps do not abort result sorting. Valid team files continue to be listed and sorted by creation date as before.

Validation

  • Tested baseline reproduction against unpatched code: injecting a corrupt JSON file or non-dict JSON into the history directory caused TeamStore.list() to fail with TypeError / ValueError.
  • Tested post-fix behavior: unreadable or non-dict files are safely bypassed, and all valid teams for the owner are returned sorted by creation time.
  • Telemetry statement: "Dashboard-api suites: 1 passed. New-test Ruff, py_compile, and diff checks pass; new regression wired into Linux CI."

Overlap check

Risk / AI disclosure

AI-assisted defect analysis, implementation, and regression test authoring. This strengthens error tolerance during state retrieval and does not alter persistence schemas, models, or network communications. Independent human review remains a gate.

Follow-up integration evidence

Composed cleanly on top of #5569, #5871, and #5875 at HEAD without conflicts. Production and test diffs passed together; adjacent pixel-agent and pixel-settings checks remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant