Skip to content

fix: extension-bridge poller + pending_queue_actions schema - #41

Merged
BaoT1301 merged 1 commit into
mainfrom
fix/extension-bridge-enqueue
May 27, 2026
Merged

BaoT1301 merged 1 commit into
mainfrom
fix/extension-bridge-enqueue

Conversation

@BaoT1301

Copy link
Copy Markdown
Collaborator

Summary

  • Poller subreddit mismatch (extension-bridge.ts): pollPendingActions was querying subreddit_id ILIKE subredditName, but the enqueue handler stores the Reddit t5_ ID in subreddit_id and the display name in subreddit_name. The query never matched, so all extension escalations/removals/approvals were silently dropped by the Devvit cron. Fixed by OR-ing across all three patterns.

  • Schema mismatch (pending_queue_actions): Table was created with id UUID which rejects the sha256 hex strings the enqueue handler inserts — every action returned 500. Columns subreddit_name and verdict_hash were also missing. Added migration 20260526000001 to fix id to TEXT and add the missing columns.

Impact

These two bugs together meant extension mod actions (escalate/remove/approve) were 100% broken on any fresh DB setup. CollabGuard UI actions were unaffected.

For Alan's DB

Run the migration manually in the Supabase SQL editor:

ALTER TABLE public.pending_queue_actions ALTER COLUMN id TYPE TEXT USING id::TEXT;
ALTER TABLE public.pending_queue_actions ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.pending_queue_actions ADD COLUMN IF NOT EXISTS subreddit_name TEXT;
ALTER TABLE public.pending_queue_actions ADD COLUMN IF NOT EXISTS verdict_hash TEXT;

Test plan

  • Escalate a comment from the extension
  • Confirm green "Escalation sent to CollabGuard queue" in extension
  • Within 60s, item appears in CollabGuard queue with extension-escalated tag

Two bugs that silently broke all extension mod actions (escalate/remove/approve):

1. Poller subreddit mismatch in extension-bridge.ts:
   pollPendingActions queried subreddit_id ILIKE subredditName, but the
   enqueue handler stores the Reddit t5_ ID in subreddit_id and the display
   name in subreddit_name. The query never matched so extension escalations
   were never picked up by the Devvit cron. Fixed by OR-ing across all three
   patterns: subreddit_name by display name, subreddit_id by display name
   (old rows), and subreddit_id by t5_ ID (new rows).

2. Schema mismatch in pending_queue_actions:
   The table was created with id UUID which rejects the sha256 hex strings
   the enqueue handler inserts, returning 500 on every action. The columns
   subreddit_name and verdict_hash were also missing. Added migration
   20260526000001 to fix id to TEXT and add the missing columns.
@github-actions

Copy link
Copy Markdown

🤖 Qwen Code Review

Summary

This PR addresses issues in the extension-bridge poller logic and fixes schema inconsistencies in the pending_queue_actions table. The changes ensure compatibility with both old and new data formats by adjusting how subreddit names are queried and by updating the database schema to support missing columns (subreddit_name, verdict_hash) and correct the id column type.

Issues

  • Schema Mismatch: The original schema had id as UUID, but the handler inserts a SHA256 hex string, causing enqueue failures.
  • Missing Columns: subreddit_name and verdict_hash were missing from pending_queue_actions, leading to errors during insertions.
  • Poller Query Logic: The poller's query for matching subreddits was inconsistent with how data is stored (subreddit_id vs subreddit_name).

Suggestions

  • Consider adding a comment or documentation to explain why id is now TEXT instead of UUID, especially since it impacts future data handling and validation.
  • Ensure that all related services (enqueue, poller, etc.) are fully aligned with the new schema to avoid runtime errors.
  • Add tests to verify that the updated poller correctly retrieves actions for both old and new data entries based on the new query logic.

Automated review by Qwen AI

@github-actions

Copy link
Copy Markdown

🤖 Qwen Code Review

Summary

This PR addresses issues in the extension-bridge poller logic and fixes schema inconsistencies in the pending_queue_actions table. The changes ensure compatibility with both old and new data formats by adjusting how subreddit names are queried, and update the database schema to support missing columns (subreddit_name, verdict_hash) and correct the id column type.

Issues

  • Schema Mismatch: The original schema had an id column defined as UUID, but the system inserts SHA256 hex strings, leading to 500 errors on enqueue calls.
  • Missing Columns: The subreddit_name and verdict_hash columns were missing from pending_queue_actions, causing insert failures.
  • Poller Logic Inaccuracy: The previous query only matched subreddit_id with subredditName, which failed due to differing storage formats between the handler and the poller.

Suggestions

  • Consider adding a comment or documentation note explaining why id is now TEXT instead of UUID, to prevent future confusion.
  • Ensure that all related functions (enqueue, poller, etc.) consistently handle the updated schema, especially around subreddit_name and verdict_hash.
  • Validate that the new .or() condition in the poller correctly handles all edge cases for matching subreddits, including potential performance implications with large datasets.

Automated review by Qwen AI

@BaoT1301
BaoT1301 merged commit 1bf3dd4 into main May 27, 2026
7 checks passed
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.

1 participant