Repository navigation
feat(prompts): make external prompt groups read-only - #17008
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79cf62c1d0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
79cf62c to
ed6ba90
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed6ba90572
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ed6ba90 to
58a613e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58a613e45b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
58a613e to
94ecb40
Compare
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
94ecb40 to
06461ac
Compare
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
06461ac to
ad4818a
Compare
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
ad4818a to
fad646f
Compare
a78bde9 to
0990874
Compare
0990874 to
3aa58a6
Compare
3aa58a6 to
1e40e77
Compare
1e40e77 to
e7ba6fe
Compare
6b7bbc9 to
dbba52d
Compare
Reject edits, deletes, new revisions, promotion and revision deletes on prompt groups whose source is not native with a read_only service error, mapped to 403 "Externally managed prompts are read-only". The guard reads the stored group, so the MANAGE_PROMPTS bypass is covered. Sharing, usage counts and resolution are unchanged. The client hides Edit and Delete for external groups, shows a read-only detail view with a Langfuse notice and keeps Share.
dbba52d to
61eecd1
Compare
Pull Request
Summary
Prompt groups with a non-native
source(Langfuse, from #16909) are owned by the external system and are recreated by a later sync, but todayPATCH /api/prompts/groups/:groupIdandDELETE /api/prompts/groups/:groupIdstill change them, promote and revision delete are blocked only because these groups have no localPromptrows, and the UI shows Edit and Delete for them.This PR makes every mutation of an external group fail with a new
read_onlyservice error, which the handlers map to403 { code: 'read_only', error: 'Externally managed prompts are read-only' }. The guard reads the stored group (the middleware-loaded record when its id matches, otherwise the database), so theMANAGE_PROMPTSACL bypass is covered too. Sharing,POST /groups/:groupId/useandGET /groups/:groupId/resolveare unchanged.In the client, the list menu hides Edit and Delete for external groups and shows a source badge, and the detail page renders a read-only view with a "Managed in Langfuse" notice and keeps Share. The group update and group delete error toasts map
read_onlyto localized copy. Prompt text display for external groups is not part of this PR.Depends on #16909 (this PR is based on its branch).
How it works
Every write path checks the stored group before validation, writes, revision reads or cache clears:
service.deletePromptGroupnow returns the service's{ ok } | errorresult;DELETE /groups/:groupIdstill responds{ message }on success.Type of change
Testing
db.promptgroups.updateOne({_id}, {$set: {source: 'langfuse', sourcePromptName: 'x', sourceProjectId: 'p', sourceDestination: 'env'}, $unset: {productionId: ''}}).PATCHandDELETEon the group return 403.Tested environments/configuration:
Automated tests:
cd packages/api && npx jest src/prompts: 198 passed. Addedread_onlycases for all five mutations (loaded group, no loaded group, mismatched loaded group), a nativedeletePromptsuccess, and 403 / no cache clear inhandlers.spec.ts.cd api && npx jest server/routes/prompts.test.js: 76 passed. 403 with the database unchanged for PATCH group, DELETE group, POST revision, PATCH production and DELETE revision, as owner and as admin;/usestill incrementsnumberOfGenerations; the owner can still share through/api/permissions; a stored group withoutsourcestays editable.cd client && npx jest components/Prompts hooks/Prompts utils/__tests__/prompts utils/__tests__/promptGroups: 83 passed. New specs forusePromptGroupPermissions,isExternalPromptGroup,disabledonPromptNameandCategorySelector,ChatGroupItemand thePromptFormread-only view.npx tsc --noEmitinpackages/apiandclient, andnode scripts/static-checks.mts --fullon the changed files: pass.Screenshots / recordings
Not captured yet. The change adds a read-only detail view, a list badge, and removes Edit/Delete from the list menu for external groups; screenshots from a local run will be added before this leaves draft.
Risk / compatibility
Additive guards only. Native groups behave the same, and there is no schema, index or migration change. Older clients receive the 403 through their existing error handling. No external groups exist before sync, so nothing changes for current users. Rollback is a revert.
Checklist
🤖 Generated with Claude Code