feat(pi): require the user's own API key for Create PR even on hosted models - #6056
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview A shared Docs/best-practices on the Pi block were updated, with new tests for visibility and hosted-model validation exemption. Reviewed by Cursor Bugbot for commit 3896d31. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryRequire the user's own API key for Pi Create PR mode even when the selected model is Sim-hosted, using one shared BYOK-only mode predicate across UI, copilot validation, and executor key resolution.
Confidence Score: 5/5Safe to merge; the three enforcement sites stay aligned and no blocking defect was found. Create PR always surfaces and retains a user key for sandbox execution, while Review Code and Local Dev keep normal hosted-key behavior; tests cover visibility and validation, and key resolution already matched this contract.
|
| Filename | Overview |
|---|---|
| apps/sim/providers/pi-providers.ts | Introduces shared isPiByokOnlyMode so Create PR BYOK enforcement cannot drift across call sites. |
| apps/sim/blocks/blocks/pi.ts | Overrides apiKey condition to always show in Create PR; other modes keep getApiKeyCondition behavior. |
| apps/sim/lib/copilot/tools/server/workflow/edit-workflow/validation.ts | Skips hosted-model apiKey stripping for Pi Create PR while preserving strip behavior for other Pi modes and LLM blocks. |
| apps/sim/executor/handlers/pi/keys.ts | Uses the shared predicate for Create PR BYOK-only resolution instead of a raw mode === cloud check. |
| apps/sim/blocks/pi-api-key-condition.test.ts | Covers Create PR visibility for hosted and unhosted models and hide/show rules for local and cloud_review. |
| apps/sim/lib/copilot/tools/server/workflow/edit-workflow/validation.test.ts | Adds hosted-model preValidate tests proving Pi Create PR keeps apiKey and other modes still strip it. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
Mode[Pi mode value]
Pred{isPiByokOnlyMode mode === cloud}
UI[Block API Key field always visible]
Val[edit-workflow keeps user apiKey]
Keys[resolvePiModelKey requires BYOK or workspace BYOK]
Hosted[Normal hosted-model hide/strip + getApiKeyWithBYOK]
Mode --> Pred
Pred -->|yes Create PR| UI
Pred -->|yes| Val
Pred -->|yes| Keys
Pred -->|no Review/Local| Hosted
Reviews (1): Last reviewed commit: "feat(pi): require the user's own API key..." | Re-trigger Greptile
310e9e0 to
3896d31
Compare
Summary
isPiByokOnlyModepredicate inproviders/pi-providers.tsconsumed by all three enforcement sites (block condition, copilot edit-workflow validation, executor key resolution) so they can't driftType of Change
Testing
Tested manually; vitest passing (validation, pi handler, new visibility tests); lint + full audit suite passing
Checklist
🤖 Generated with Claude Code