name: n8n-supabase-workflow-debug
description: Debug n8n workflows connecting to Supabase REST API — common bugs, SQL updates, and workflow_history management on self-hosted Docker n8n
n8n + Supabase REST API Integration Debugging
Context
Debugging n8n workflows that connect to Supabase via REST API on self-hosted n8n (VPS Docker).
Common Issues and Solutions
1. n8n Supabase Node Bugs
The native n8n-nodes-base.supabase node has bugs with filters (select conditions) and fieldsUi parameters — errors like:
- -
"At least one select condition must be defined"— even when match column IS set - -
"propertyValues[itemName] is not iterable"— internal node error - -
"Cannot read properties of undefined (reading 'node')"— internal n8n error - -
"versionId"— NOTversionId - -
"workflowId"— NOTworkflowId - -
"createdAt"— NOTcreatedAt - -
PATCH /rest/workflows/{id}— partial update (nodes only, no version bump) - -
PUT— full replace, creates new versionId - - After PATCH: manually update
workflow_historywith the same nodes, using currentactiveVersionId - -
workflow_entity.activeVersionId= points toworkflow_history.versionIdof the ACTIVE published version - -
workflow_entity.versionId= the latest saved (draft) version - - Publishing via UI creates a new
workflow_historyentry and updatesactiveVersionId - -
PATCHvia API only updatesworkflow_entity.nodes, NOTworkflow_history— need to update both manually
Solution: Use n8n-nodes-base.httpRequest instead of the native Supabase node. Works perfectly.
2. Supabase REST API via HTTP Request Node
`
URL: https://{project}.supabase.co/rest/v1/{table}?on_conflict={conflict_column}
Method: POST
Headers:
- apikey: {anon_key}
- Authorization: Bearer {anon_key}
- Prefer: resolution=merge-duplicates (for upsert)
- Content-Type: application/json
Body (specifyBody=json, jsonBody):
= {{ $json.data }} (from Code node transform)
`
3. workflow_history Table
n8n stores published workflow versions in workflow_history. Column names are case-sensitive and require double quotes:
4. SQL UPDATE with JSON Content
When updating workflow_history.nodes directly via SQL, use dollar-quoting to avoid escaping issues:
`sql
UPDATE workflow_history
SET nodes = $json${"nodes": [...]}$json$
WHERE "versionId" = 'uuid-here';
`
NOT E'...' syntax — dollar-quoting is cleaner.
5. Updating Workflow via REST API
6. n8n Database Access (Docker)
`bash
docker exec -i n8n-postgres psql -U n8n -d n8n -c "SELECT ..."
`
Python on VPS for complex SQL updates:
`python
import subprocess
script = """
import json, subprocess
with open('/tmp/workflow_nodes.json') as f:
nodes = json.load(f)
nodes_json = json.dumps(nodes)
active_vid = 'uuid-from-workflow-entity'
sql = 'UPDATE workflow_history SET nodes = $json$' + nodes_json + '$json$ WHERE "versionId" = \\'' + active_vid + '\\';'
subprocess.run(['docker', 'exec', '-i', 'n8n-postgres', 'psql', '-U', 'n8n', '-d', 'n8n', '-c', sql], capture_output=True, text=True)
"""
Upload script to VPS via SCP, then run via SSH
`
7. Finding Real Column Names in Supabase
`bash
curl "https://{project}.supabase.co/rest/v1/{table}?limit=1" \
-H "apikey: {anon_key}" \
-H "Authorization: Bearer {anon_key}"
`
Check the returned JSON keys — column names in Supabase REST are case-sensitive.
8. Workflow Entity Key Columns
`sql
SELECT id, name, active, "activeVersionId", "versionId"
FROM workflow_entity
WHERE name LIKE '%keyword%';
`
Workflow History Structure
Debugging Commands
`bash
Check workflow executions
docker exec n8n-postgres psql -U n8n -d n8n -c \
'SELECT id, "workflowId", status, finished, mode, "startedAt", "stoppedAt" FROM execution_entity WHERE "workflowId" = '\''{id}'\'' ORDER BY "startedAt" DESC LIMIT 5;'
Check execution data (error details)
docker exec n8n-postgres psql -U n8n -d n8n -c \
'SELECT data FROM execution_data WHERE "executionId" = {exec_id};'
`
n8n REST API Authentication
Login via API to get session cookie:
`bash
curl -s -c cookies.txt https://n8n.example.com/rest/login \
-X POST -H "Content-Type: application/json" \
-d '{"emailOrLdapLoginId": "user@email.com", "password": "pass"}'
`
Then use -b cookies.txt for subsequent authenticated requests.
Supabase Anon Key Format
sb_ prefix = Share Bucket (wrong), sbp_ prefix = Project API key (also not the anon key).
The anon key is a JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... — decode the second part to find project ref.