fix(ai-connectors): move fallbackStrategy out of SalesPrompt.salesPrompt JSON to prevent overwrite race
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 58/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- postgresql, typescript
Research direction
Read apps/api/src/ai-connectors/ai-connectors.service.ts around getFallbackStrategy and saveFallbackStrategy, then inspect the SalesPrompt model in packages/prisma/schema.prisma and the related Prisma migration setup. Trace how the current JSON value is read and written, including the legacy fallback path. Done means fallback settings use a dedicated nullable column, existing JSON settings remain readable, and saving fallback settings leaves salesPrompt unchanged.
Written by the indexing model from the issue text.
Description
Problem Description
In apps/api/src/ai-connectors/ai-connectors.service.ts (saveFallbackStrategy, lines 432-469), fallback settings are stored inside the same SalesPrompt.salesPrompt JSON string as the main AI Sales Prompt. saveFallbackStrategy reads the entire salesPrompt, parses it, mutates fallbackStrategy, and writes the whole string back.
If an admin edits the Sales Prompt concurrently with a Fallback Strategy update, the second write silently overwrites the first.
Expected Behavior
- Saving
fallbackStrategymust never overwriteSalesPrompt.salesPrompt. - Existing workspaces that currently have
fallbackStrategystored insidesalesPromptJSON must continue to work seamlessly with zero data loss.
Where to Look
apps/api/src/ai-connectors/ai-connectors.service.ts(getFallbackStrategy,saveFallbackStrategylines 432-469)packages/prisma/schema.prisma(SalesPrompt)
Solution / Implementation Guide (Zero-Breakage Way)
- Add a nullable
fallbackStrategy Json?column toSalesPromptinpackages/prisma/schema.prisma(via Prisma migration). - In
getFallbackStrategy:- Read
record.fallbackStrategyfirst; ifnull, fall back to parsingfallbackStrategyfromrecord.salesPromptJSON so existing workspaces keep their settings.
- Read
- In
saveFallbackStrategy:- Update only the dedicated
fallbackStrategycolumn viaprisma.salesPrompt.upsert/update, leavingsalesPromptuntouched.
- Update only the dedicated
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 1
- Avg merge
- 6m
- Merged PRs (30d)
- 27
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sumamakhan761/tryinstance
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#65 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
sumamakhan761/tryinstance#64 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
sumamakhan761/tryinstance#63 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#62 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#60 ·
Maintainers usually reply within 1 day
All issues in sumamakhan761/tryinstance
Similar issues
-
prio:low scope:hud
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OliverRomhagen/vrigstad-joyride#953 ·
Maintainers usually reply within 1 day
-
review-followup
Difficulty 1/5 Under an hour Newbie friendliness 92/100
griffinwork40/agent-afk#5446 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
kacper-szewczyk/Ticknest#346 ·
Maintainers usually reply within 1 day
-
echarts geo: a GeoJSON URL that returns 200 with a body that is not JSON is fetched on each refreshOpenbug plugin/echarts/geo
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Yeachan-Heo/gajae-code#8230 ·
Maintainers usually reply within 1 day