fix(ai): harden Prompts.get_all against old servers and malformed rows - #942
Conversation
posthog-python Compliance ReportDate: 2026-09-11 09:00:37 UTC ✅ All Tests Passed!111/111 tests passed Capture_V1 Tests✅ 94/94 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
|
Reviews (1): Last reviewed commit: "fix(ai): fail get_all when any returned ..." | Re-trigger Greptile |
marandaneto
left a comment
There was a problem hiding this comment.
found an issue, see comment, approving to unblock
marandaneto
left a comment
There was a problem hiding this comment.
Automated advisory code review.
| compat_error, name="*", version=None, label=label | ||
| ) | ||
| raise compat_error | ||
| if label_state == "moved": |
There was a problem hiding this comment.
blocking: Preserve rejection when no rows resolve the label — An old server can return latest versions while every prompt’s production label points to an earlier version. These rows are now classified as "moved" and skipped; removing the final no-results guard makes get_all() return {} instead of raising the compatibility error. This silently reports no matching prompts despite labeled prompts existing, regressing the previous behavior. Preserve rejection or otherwise verify resolution before accepting an entirely skipped batch. Reproduction: reproduced — uv run --no-sync python -m pytest -q --timeout=30 test_review_get_all.py fails on head with DID NOT RAISE for a mocked list response containing latest version 2 labeled at version 1, and passes on the merge base.
💡 Motivation and Context
Review of the posthog-js port (PostHog/posthog-js#4903) found two gaps that also exist in the merged
Prompts.get_all(#938):labelparam, prompts whose label happens to point at the latest version still pass the row check.get_allthen returns that subset as a complete result, silently missing the rest. The old guard only fired when no row passed.Best to land before
get_allships to PyPI, so the first published version has the hardened behavior.Changes
all_labelsdoes not contain the label at all can only come from a server that did not filter, so even one such row makesget_allraise. A label present at a different version stays the benign mid-request race: skip and warn._maybe_capture_error, like the other fetch failures.💚 How did you test it?
📝 Checklist
If releasing new changes
.sampo/changesets/(written by hand, same format assampo add)🤖 Agent context
Autonomy: Human-driven (agent-assisted)
__proto__fix from that review does not apply here: Python dicts have no prototype.