feat(prompts): Fetch prompts by label#744
Merged
Merged
Conversation
jurajmajerik
marked this pull request as ready for review
July 16, 2026 12:44
Contributor
|
Reviews (1): Last reviewed commit: "feat(prompts): fetch prompts by label" | Re-trigger Greptile |
Contributor
posthog-python Compliance ReportDate: 2026-07-17 09:50:09 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
|
Radu-Raicea
approved these changes
Jul 16, 2026
Radu-Raicea
left a comment
Member
There was a problem hiding this comment.
You should bump the library version and add whatever label is necessary to publish this new version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PostHog prompt management is gaining labels: movable pointers from a name like
productionto exactly one version of a prompt, so a version can be released or rolled back without a code deploy (PostHog/posthog#70862, PostHog/posthog#71509). The SDK can fetch a prompt by name or by version number, but not by label — and fetching by label is the way labels are meant to be consumed.Changes
Adds a
labelparameter toPrompts.get():labelis passed as a query param on the existing fetch endpoint; mutually exclusive withversion(raisesValueErrorif both are given, matching the API's 400)PromptResultand the cache carry alabelfield, so callers can see which label a prompt resolved throughDraft until the backend PR (PostHog/posthog#71509) is deployed: the API ignores unknown query params, so releasing this first would send
label=productionand silently get the latest version back.How did you test this code?
New unit tests: the label query param is sent and label metadata comes back on
PromptResult, version+label together raises, and labeled fetches are cached separately from latest fetches (without the cache-key change, a labeled fetch after a latest fetch silently returns the wrong version). Fulltest_prompts.pysuite passes (61 tests), ruff and mypy clean.