Repository navigation
supabase integration - #472
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #470.
What this adds
A full Supabase integration: one connected account covers every project the user can reach.
api.supabase.com/v1): projects, organizations, SQL, migrations, edge functions, branches, secrets, logs, security/performance advisors, service config.<ref>.supabase.co): table rows (PostgREST), storage files, auth users, edge-function calls. The project's secret key is fetched through the Management API on first use and kept in memory only. Users paste one token, never a per-project key, and the agent never sees the secret key.71 operations in 10 action sets, plus a 24-op
supabaseshortlist set. It follows the full-port shape (craftos_integrations/providers/supabase/) and passesscripts/verify_integration.py supabase.Auth: a personal access token (
sbp_…) today. OAuth (PKCE, refresh) is implemented and turns on automatically onceSUPABASE_SHARED_CLIENT_ID/_SECRETare set:auth_typereportsbothonly then, so the UI never offers a button that can't work. Project keys pasted by mistake (sb_secret_,sb_publishable_, anon/service_role JWTs) are rejected before any request.Safety:
jwt_secretand SMTP passwords are never returned.Changes outside the provider
app/action/action_set.pysupabase_storage: 12 actions: buckets, files, signed_url) instead ofCustom action set: <name>. Shortlist sets say they're a shortlist. Applies to all 179 sets; about +1.2k tokens in the cached prompt prefix.craftos_integrations/core/system.pydefault_alias(credential)). Never overwrites a user's rename; a taken name is skipped.IntegrationsSettings.tsxintegration_management.py,app/config.py,app/agent_base.pyconnect_integrationhints and the OAuth client-credential wiring.Testing
Run end to end: CraftBot from this branch, a real Supabase account, agent model gpt-5.2, scratch project Test. Everything created during testing was removed afterwards.
pytest tests/integrations tests/test_action_set_catalog.pyapp.usage.pricing).scripts/smoke_supabase.py --connected --writeAgent scenarios
curlcreate_notes_table_enable_rlsAlso tested live: connect edge cases (empty,
sb_secret_,sb_publishable_, JWT, fakesbp_→ real 401), pause → restore (76s / 200s), Postgres + auth config writes.Bugs found live and fixed in this PR
/v1/profilereturns 403 for personal access tokens. Validity is now checked with/v1/organizations; the account is identified by a token fingerprint.logs.all(410). Queries now use the unifiedlogstable (ClickHouse SQL, filtered bysource_name).{"error": …}in the body; this is now treated as a failure.CREATE TABLEhit PostgREST's stale schema cache (PGRST205). The client now asks PostgREST to reload and retries.match().storage/auth/vaultand told the user to use the dashboard. Fixed in the guidance plus the catalog change above; the re-test passed.Not covered
http://localhost:8765) and its id/secret.SELECT 1, while other analytics worked. The integration retries once, then explains.Screenshots
Connecting (7)
Supabase card, connected

Connect dialog with credential help

Edge case: nothing pasted

Edge case: project secret key rejected

Edge case: publishable key rejected

Edge case: anon/service_role JWT rejected

Settings: account named Test, read-only mode, max rows

Agent scenarios (16)
Before connecting: agent asks how to connect

Before connecting: explains only a token works

1. Projects and health

2. Table with RLS and three rows

3. Update and filtered read

4. Bulk delete asks first

4. Cancel respected

5. Bucket, upload, signed link

6. Secret, deploy, invoke

7. Auth user and security advisors

8–10. Missing table, invalid project, failing logs

11. Read-only mode refuses the write

11. Reads still work

12. Cleanup asks for confirmation

12. Bug 7 before the fix

12. After the fix

Re-tests after fixes (2)
13. Create a table: recorded as a migration

14. Create project: 403 explained

How to try it
python scripts/smoke_supabase.py --connected [--project-ref <ref>] [--write]. Use a scratch project for--write.