Skip to content

fix(db): add tenant_id to save_public_agent_message function#38

Merged
peterod99 merged 1 commit intomainfrom
claude/fix-funnel-display-zH4Bd
Jan 6, 2026
Merged

fix(db): add tenant_id to save_public_agent_message function#38
peterod99 merged 1 commit intomainfrom
claude/fix-funnel-display-zH4Bd

Conversation

@peterod99
Copy link
Copy Markdown
Owner

@peterod99 peterod99 commented Jan 6, 2026

The public_agent_messages table requires tenant_id but the RPC function wasn't setting it, causing message saves to fail silently. Now the function gets tenant_id from the current tenant context or falls back to the agent's tenant_id.

Summary by CodeRabbit

Bug Fixes

  • Fixed public agent message storage to ensure conversations are properly retained and accessible.

✏️ Tip: You can customize this high-level summary in your review settings.

The public_agent_messages table requires tenant_id but the RPC function
wasn't setting it, causing message saves to fail silently. Now the
function gets tenant_id from the current tenant context or falls back
to the agent's tenant_id.
@peterod99 peterod99 merged commit dd66d7e into main Jan 6, 2026
1 of 2 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 6, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

A new PostgreSQL migration adds the save_public_agent_message function to persist public agent messages with automatic tenant_id assignment. The function resolves tenant_id via the current session context or the associated agent record, then inserts the message with all provided metadata.

Changes

Cohort / File(s) Summary
Database Migration
supabase/migrations/20260106133948_fix_save_public_agent_message_tenant_id.sql
New function public.save_public_agent_message() added to handle insertion of public agent messages with tenant_id resolution logic; supports fallback from agent_id lookup; includes security definer and inet type casting for IP address

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A message saved with tenant care,
Through lookup paths we know are there,
With fallback logic, clean and bright,
This function gets the tenant right!
Hops forward now, no more dismay,
Security sealed, hooray, hooray! 🌟


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 94b9abf and b105f25.

📒 Files selected for processing (1)
  • supabase/migrations/20260106133948_fix_save_public_agent_message_tenant_id.sql

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants