Skip to content

fix(ai): throw when every getAll row was skipped as moved - #4961

Merged
jurajmajerik merged 3 commits into
mainfrom
prompts-get-all-all-moved-guard
Sep 15, 2026
Merged

jurajmajerik merged 3 commits into
mainfrom
prompts-get-all-all-moved-guard

Conversation

@jurajmajerik

Copy link
Copy Markdown
Contributor

Problem

Changes

  • After validation, if the server returned rows but every one was skipped as moved, getAll throws the compatibility error instead of returning an empty object. A single moved row among resolved ones stays a skip with a warning.
  • Same fix as posthog-python#942 commit 8d26eb1, which already shipped in posthog 7.53.0.

Release info Sub-libraries affected

Libraries affected

  • @posthog/ai

Checklist

  • Tests for new code
  • Accounted for the impact of any changes across different platforms
  • Accounted for backwards compatibility of any changes (no breaking changes!)
  • Took care not to unnecessarily increase the bundle size

If releasing new changes

  • Changeset added in .changeset/ (written by hand, same format as pnpm changeset)

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

  • Written with Claude Code, directed by the assignee. Ports the fix from marandaneto's review finding on the Python PR back to the JS SDK, where the same guard was removed in the same restructure.

@jurajmajerik jurajmajerik self-assigned this Sep 14, 2026
@greptile-apps

greptile-apps Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
.changeset/prompts-get-all-all-moved-guard.md:5
**Changeset is too detailed**

This description uses multiple sentences and explains implementation details. Repository guidance requires one short, user-facing line that states the fix or feature, so this must be shortened before merging.

```suggestion
Fix `prompts.getAll` returning an empty result when the server cannot resolve the requested label.
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(ai): throw when every getAll row was..." | Re-trigger Greptile

'@posthog/ai': patch
---

`prompts.getAll` now throws the server-compatibility error when the server returned prompts but none resolve the requested label, instead of returning an empty result. This happens on PostHog servers without label support on the prompt list endpoint when every label points at an older version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Changeset is too detailed

This description uses multiple sentences and explains implementation details. Repository guidance requires one short, user-facing line that states the fix or feature, so this must be shortened before merging.

Suggested change
`prompts.getAll` now throws the server-compatibility error when the server returned prompts but none resolve the requested label, instead of returning an empty result. This happens on PostHog servers without label support on the prompt list endpoint when every label points at an older version.
Fix `prompts.getAll` returning an empty result when the server cannot resolve the requested label.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: .changeset/prompts-get-all-all-moved-guard.md
Line: 5

Comment:
**Changeset is too detailed**

This description uses multiple sentences and explains implementation details. Repository guidance requires one short, user-facing line that states the fix or feature, so this must be shortened before merging.

```suggestion
Fix `prompts.getAll` returning an empty result when the server cannot resolve the requested label.
```

**Context Used:** AGENTS.md ([source](https://github.com/posthog/posthog-js/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 9a7479f

@jurajmajerik
jurajmajerik marked this pull request as ready for review September 14, 2026 18:19
@jurajmajerik
jurajmajerik requested a review from a team as a code owner September 14, 2026 18:19
resolvedRows.push(row)
}

if (rows.length > 0 && resolvedRows.length === 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsdocs should mention the method throws
ideally it should not throw at all but all the other methods do that already

@jurajmajerik
jurajmajerik merged commit 8fb9367 into main Sep 15, 2026
59 checks passed
@jurajmajerik
jurajmajerik deleted the prompts-get-all-all-moved-guard branch September 15, 2026 09:52
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.

2 participants