Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(llma): fix tagger saves failing on fractional % and blank tags (#59894)

Andrew Maguire26105f410a98
diff --git a/products/llm_analytics/backend/api/taggers.py b/products/llm_analytics/backend/api/taggers.py
index ea2ecd262bd7..0c1f7d1187e3 100644
--- a/products/llm_analytics/backend/api/taggers.py
+++ b/products/llm_analytics/backend/api/taggers.py
@@ -53,8 +53,11 @@ class TagDefinitionSerializer(serializers.Serializer):
class TaggerConditionSerializer(serializers.Serializer):
id = serializers.CharField(max_length=100, help_text="Stable identifier for this condition")
- rollout_percentage = serializers.IntegerField(
- default=100, min_value=0, max_value=100, help_text="Percentage of matching events to apply this condition to"
+ rollout_percentage = serializers.FloatField(
+ default=100,
+ min_value=0,
+ max_value=100,
+ help_text="Percentage of matching events to apply this condition to",
)
properties = serializers.ListField(
child=serializers.DictField(),
diff --git a/products/llm_analytics/backend/api/test/test_taggers.py b/products/llm_analytics/backend/api/test/test_taggers.py
index 40623c4be891..255fb71b1c8f 100644
--- a/products/llm_analytics/backend/api/test/test_taggers.py
+++ b/products/llm_analytics/backend/api/test/test_taggers.py
@@ -337,6 +337,22 @@ class TestTaggersApi(APIBaseTest):
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
+ @parameterized.expand([("fractional", 33.3), ("slider_minimum", 0.1), ("whole", 50)])
+ def test_can_save_fractional_rollout_percentage(self, _name: str, rollout_percentage: float):
+ response = self.client.post(
+ f"/api/environments/{self.team.id}/taggers/",
+ {
+ "name": "Feature Tagger",
+ "tagger_config": _make_tagger_config(),
+ "conditions": [{"id": "cond-1", "rollout_percentage": rollout_percentage, "properties": []}],
+ },
+ format="json",
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED, response.json()
+ tagger = Tagger.objects.get(id=response.data["id"])
+ assert tagger.conditions[0]["rollout_percentage"] == rollout_percentage
+
def test_patch_tagger_type_without_fresh_config_is_rejected(self):
tagger = Tagger.objects.create(
name="LLM tagger",
diff --git a/products/llm_analytics/frontend/tags/llmTaggerLogic.test.ts b/products/llm_analytics/frontend/tags/llmTaggerLogic.test.ts
index 93b10f0fc65b..1e358974c405 100644
--- a/products/llm_analytics/frontend/tags/llmTaggerLogic.test.ts
+++ b/products/llm_analytics/frontend/tags/llmTaggerLogic.test.ts
@@ -359,9 +359,29 @@ describe('llmTaggerLogic', () => {
expect(errors.tagger_config.prompt).toBe('Prompt is required')
})
- it('reports error when tag name is empty', async () => {
+ it('does not block save when a blank tag row coexists with a named tag', async () => {
+ // "Add tag" appends a blank row and submit strips blank rows, so a blank row must
+ // not invalidate the whole form — otherwise unrelated edits (conditions, enabled,
+ // sampling) silently fail to save until the row is removed.
+ logic.actions.setTaggerFormValues({
+ name: 'Valid Tagger',
+ tagger_config: {
+ prompt: 'Tag this',
+ tags: [
+ { name: 'billing', description: '' },
+ { name: '', description: '' },
+ ],
+ min_tags: 0,
+ max_tags: null,
+ },
+ })
+ const errors = await submitAndGetErrors()
+ expect(errors.tagger_config.tags).toBeUndefined()
+ })
+
+ it('reports error when every tag row is blank', async () => {
const errors = await submitAndGetErrors()
- expect(errors.tagger_config.tags).toEqual([{ name: 'All tags must have a name' }])
+ expect(errors.tagger_config.tags).toEqual([{ name: 'At least one tag is required' }])
})
it('reports error when no tags exist', async () => {
diff --git a/products/llm_analytics/frontend/tags/llmTaggerLogic.ts b/products/llm_analytics/frontend/tags/llmTaggerLogic.ts
index 73774238a09c..b45c25199d5c 100644
--- a/products/llm_analytics/frontend/tags/llmTaggerLogic.ts
+++ b/products/llm_analytics/frontend/tags/llmTaggerLogic.ts
@@ -245,19 +245,16 @@ export const llmTaggerLogic = kea<llmTaggerLogicType>([
prompt: !('prompt' in values.tagger_config && values.tagger_config.prompt)
? 'Prompt is required'
: undefined,
- // kea-forms expects per-tag errors as an array matching tags[]. The
- // array type does not allow `undefined` slots, so use `{}` for
- // tags with no error. Synthesize a single-entry error for the
- // empty-tags case so the form stays invalid (the UI guardrail
- // blocks reaching this state, but a programmatic removeTag could).
+ // Blank tag rows are stripped on submit (see below), so they must not
+ // block saving — otherwise the empty row that "Add tag" appends silently
+ // invalidates the whole form, and unrelated edits (conditions, enabled,
+ // sampling) appear unsavable until the row is removed. Only require that
+ // at least one named tag survives the strip. The single-entry array is
+ // how kea-forms keeps the form invalid for the no-named-tags case.
tags:
- values.tagger_config.tags.length === 0
+ values.tagger_config.tags.filter((t) => t.name.trim()).length === 0
? [{ name: 'At least one tag is required' }]
- : values.tagger_config.tags.some((t) => !t.name.trim())
- ? values.tagger_config.tags.map((t) =>
- !t.name.trim() ? { name: 'All tags must have a name' } : {}
- )
- : undefined,
+ : undefined,
},
}),
submit: async (values: TaggerForm) => {