Commit Graph

1947 Commits

Author SHA1 Message Date
gpt-engineer-app[bot]
28fa2fd0d4 Monitor rate limits progress
Implement monitor-rate-limits edge function to compare metrics against alert configurations, trigger notifications, and record alerts; update config and groundwork for admin UI integration.
2025-11-11 00:19:13 +00:00
gpt-engineer-app[bot]
677d0980dd Connect to Lovable Cloud
Approved Lovable tool use and migration updates to fix security warning and add monitoring edge function. Prepare and apply migrations to ensure search_path is set to public and implement monitoring endpoint for rate limit metrics.
2025-11-11 00:14:48 +00:00
gpt-engineer-app[bot]
1628753361 Create Rate Limit Admin Dashboard
Add a React admin dashboard component to visualize rate limit metrics and statistics, including data fetching from the rate-limit-metrics edge function, charts and statistics, and admin routes/integration. Includes setup for routing and UI scaffolding to display total requests, block rate, top blocked IPs/users, and recent activity with interactive charts.
2025-11-11 00:06:49 +00:00
gpt-engineer-app[bot]
f15190351d Create rate-limit-metrics edge function
Add an edge function rate-limit-metrics to expose metrics via API, including authentication guards, CORS headers, and multiple query endpoints for recent metrics, stats, and function/user/IP-specific data. Integrates with new metrics and auth helpers and uses existing rate limiter.
2025-11-11 00:02:55 +00:00
gpt-engineer-app[bot]
fa444091db Integrate metrics and auth
Add Phase 2 updates to rateLimiter.ts:
- Import and hook in rateLimitMetrics and authHelpers
- Track per-request metrics on allowed/blocked outcomes
- Extract userId and clientIP for metrics
- Extend RateLimiter to pass functionName for metrics context
- Update withRateLimit to utilize new metadata and return values
2025-11-11 00:01:13 +00:00
gpt-engineer-app[bot]
bea3031767 Create rateLimitMetrics and authHelpers
Implement Phase 1 by adding:

- supabase/functions/_shared/rateLimitMetrics.ts: in-memory rate limit metrics utilities (record, query, stats, clear, and helpers)
- supabase/functions/_shared/authHelpers.ts: auth helpers for extracting userId, client IP, and rate-limit keys (code scaffolding)
2025-11-10 23:57:35 +00:00
gpt-engineer-app[bot]
6da29e95a4 Add rate limiting to high-risk
Introduce centralized rate limiting by applying defined tiers (STRICT, STANDARD, LENIENT, MODERATE) to high-risk edge functions:
- export-user-data (STRICT, 5 req/min)
- send-contact-message (STANDARD, 20 req/min)
- validate-email-backend (LENIENT, 30 req/min)
- admin-delete-user, resend-deletion-code (MODERATE)
- additional standard targets identified (request-account-deletion, cancel-account-deletion) as per guidance

Implements:
- Wrapped handlers with withRateLimit using centralized rateLimiters
- Imported from shared rate limiter module
- Annotated with comments explaining tier rationale
- Updated three initial functions and extended coverage to admin/account management functions
- Added documentation guide for rate limiting usage

This aligns with the Rate Limiting Guide and centralizes rate limit configuration for consistency.
2025-11-10 21:39:37 +00:00
gpt-engineer-app[bot]
ed6ddbd04b Centralize rate limiting config
Create shared rateLimitConfig.ts with tiers (strict, moderate, lenient, generous, per-user variants) and update edge functions to import centralized rate limiters. Replace inline rate limiter usage with new config, preserving backward compatibility. Add documentation guide for rate limiting usage.
2025-11-10 21:33:08 +00:00
gpt-engineer-app[bot]
bf3da6414a Centralize CORS configuration
Consolidate CORS handling by introducing a shared supabase/functions/_shared/cors.ts and migrate edge functions to import from it. Remove inline cors.ts usage across functions, standardize headers (including traceparent and x-request-id), and prepare for environment-aware origins.
2025-11-10 21:28:46 +00:00
gpt-engineer-app[bot]
7cbd09b2ad Add missing CORS headers
Updated edge functions to include traceparent and x-request-id in Access-Control-Allow-Headers for:
- supabase/functions/process-selective-approval/cors.ts
- supabase/functions/process-selective-rejection/cors.ts

This fixes CORS preflight and allows POST requests to reach edge functions.
2025-11-10 21:22:30 +00:00
gpt-engineer-app[bot]
dc12ccbc0d Enable JWT for rejection function
Update supabase/config.toml to set verify_jwt = true for process-selective-rejection, aligning platform authentication with function usage and allowing POST requests to reach the edge function.
2025-11-10 21:09:37 +00:00
gpt-engineer-app[bot]
1b765a636c Enable JWT verification for process-selective-approval
Update supabase/config.toml to set verify_jwt = true for the process-selective-approval function, aligning platform authentication with the function’s requirements and allowing authenticated POST requests to reach the edge function.
2025-11-10 20:56:18 +00:00
gpt-engineer-app[bot]
f9e6c28d06 Add defensive logging to edge function
Enhance process-selective-approval with startup env var validation, request-level logging, and improved error handling to diagnose edge function failures. Includes checks for SUPABASE_ANON_KEY, startup init log, per-request logs, and robust catch-block logging.
2025-11-10 20:22:25 +00:00
gpt-engineer-app[bot]
95c352af48 Connect to Lovable Cloud
Approve and apply migration to fix RPC for park location data
- Update TypeScript types to remove temp_location_data
- Create migration to fix create_submission_with_items by using relational park_submission_locations
- Ensure _temp_location is extracted and stored properly
2025-11-10 20:13:27 +00:00
gpt-engineer-app[bot]
f3f67f3104 Create RPC fix migration and types
Update database migration to fix create_submission_with_items to use relational park_submission_locations for location data, removing temp_location_data usage; add corresponding TypeScript type cleanup to drop temp_location_data field from submission data types.
2025-11-10 20:05:52 +00:00
gpt-engineer-app[bot]
1f7e4bf81c Fix updateItemDataWithHistory
Refactor to store park location data relationally:
- Retrieve park_submission_id from park_submissions
- Remove embedded temp_location_data usage
- Update park_submissions without location, then upsert location into park_submission_locations
- Align behavior with updateSubmissionItems pattern to fix JSON storage in Item history
2025-11-10 19:53:29 +00:00
gpt-engineer-app[bot]
b1c518415d Refactor moderation tests to use submission helpers
Refactor src/lib/integrationTests/suites/moderationDependencyTests.ts to replace direct submission_items inserts with proper submission helper usage (submitParkCreation), aligning with relational schema. Update dep-001 to create parks via helpers and adjust item retrieval/cleanup accordingly. Modify dep-002 to verify relational submission structure via helpers, ensuring tests interact with new schema and avoid legacy item_data usage. This fixes schema/mapping mismatches and aligns tests with the approved Phase 2 approach.
2025-11-10 19:50:30 +00:00
gpt-engineer-app[bot]
8259096c3f Add cleanup verification UI
Implements a CleanupReport UI component to display detailed cleanup results after test runs, including tables cleaned, records deleted per table, duration, and errors. Integrates with IntegrationTestRunner to show cleanup summary post-run and exports a compact inline view.
2025-11-10 19:30:30 +00:00
gpt-engineer-app[bot]
f51d9dcba2 Create test data cleanup utility
Adds a new test data cleanup utility to safely remove test fixtures after integration test suites. Includes type-safe cleanup functions for parks, rides, companies, ride_models, locations, and submissions, with safety checks (is_test_data filters) and progress logging. Integrates cleanup invocation post-run to prevent database bloat and preserves safety against prod data deletion.
2025-11-10 19:28:13 +00:00
gpt-engineer-app[bot]
ea22ab199f Connect to Lovable Cloud
Add phase 2 migration for moderator INSERT policies and enhance test runner rate-limit mitigations:
- Introduce migration 20251110_fix_missing_insert_policies_phase2.sql to grant moderator INSERT capabilities for park_submission_locations, parks, rides, companies, ride_models, and locations with MFA checks.
- Update test runner to 8s base delays, preemptive cooldowns before heavy suites, and 18s post-suite delays for heavy suites, improving rate-limit handling.
2025-11-10 19:24:50 +00:00
gpt-engineer-app[bot]
73e847015d Add rate limit aware retries
Enhance retry logic to detect 429 rate limits, parse Retry-After headers, and apply smart backoff across all entity submissions. Adds rate-limit-aware backoff, preserves user feedback via UI events, and ensures retries respect server-provided guidance.
2025-11-10 19:05:31 +00:00
gpt-engineer-app[bot]
8ed5edbe24 Implement automatic retry in entitySubmissionHelpers.ts
Add exponential backoff retry logic with user feedback
- Integrate with existing withRetry patterns
- Introduce unique retry IDs for submissions
- Emit consistent UI events for retry progress, success, and failure
- Enhance rate-limit handling including Retry-After scenarios
- Standardize baseDelay and shouldRetry across park, ride, company, ride_model, and other submissions
2025-11-10 19:02:11 +00:00
gpt-engineer-app[bot]
496ff48e34 Connect to Lovable Cloud
Implemented end-to-end fixes:
- Added INSERT RLS policies for park_submissions, ride_submissions, company_submissions, ride_model_submissions, and photo_submissions (own submissions and moderator access)
- Fixed process_approval_transaction to replace ride_type with category and updated references accordingly
- Enhanced rate limiting in testRunner.ts with a 6s base delay and 12s adaptive delays after submission-heavy suites
2025-11-10 18:34:14 +00:00
gpt-engineer-app[bot]
b47d5392d5 Enhance formatTestError patterns
Adds comprehensive error pattern matching in formatTestError to detect and format Supabase constraint violations (RLs, not-null, unique, foreign keys, check constraints, and related schema/permission issues) into actionable messages, extracting relevant details for clearer test failure guidance. Includes handling for common error shapes and preserves fallback messaging.
2025-11-10 18:22:00 +00:00
gpt-engineer-app[bot]
c5d40d07df Connect to Lovable Cloud
Apply quick wins and pipeline fixes for integration tests:
- Remove is_test_data flag from location inserts
- Increase test delay from 2.5s to 5s and add delays between suites to curb rate limiting
- Replace [object Object] error formatting with formatTestError across 10 test suites (31 edits) and add import
- Refactor unit/conversion tests and performance tests to use the approval pipeline
- Extend edge function handling by ensuring item_ids are included in idempotency key inserts (edge function fix)
- Update auth, data integrity, edgeFunction, moderation, performance, submission, unitConversion, and versioning test files accordingly
2025-11-10 18:20:22 +00:00
gpt-engineer-app[bot]
2d65f13b85 Connect to Lovable Cloud
Add centralized errorFormatter to convert various error types into readable messages, and apply it across edge functions. Replace String(error) usage with formatEdgeError, update relevant imports, fix a throw to use toError, and enhance logger to log formatted errors. Includes new errorFormatter.ts and widespread updates to 18+ edge functions plus logger integration.
2025-11-10 18:09:15 +00:00
gpt-engineer-app[bot]
4a18462c37 Add delay countdown UI progress
Introduce visible countdown indicators for rate-limit delays between tests:
- Extend test runner to emit and expose delay progress updates.
- Update IntegrationTestRunner UI to display countdown while pausing.
- Ensure users see why tests are paused during delays.
2025-11-10 17:34:53 +00:00
gpt-engineer-app[bot]
f7f22f4817 Add delays between tests
Introduce automatic delay between test executions in the test runner to prevent rate limiting. Added a delayBetweenTests config (default 2.5s), a delay() helper, and updated runSuite to wait between tests. This helps avoid "Too many submissions in a short time" errors during test runs.
2025-11-10 17:33:43 +00:00
gpt-engineer-app[bot]
ade1810a01 Improve error formatting in tests
- Replace [object Object] errors with readable messages by using robust error formatting across test suites
- Introduce formatTestError helper and apply it in all catch blocks and error throws
- Update approvalPipelineTests and related suites to utilize improved error extraction for better debugging
2025-11-10 17:03:25 +00:00
gpt-engineer-app[bot]
e0001961bf Refactor tests to use pipeline
Refactor versioningTests.ts, submissionTests.ts, and dataIntegrityTests.ts to replace direct DB inserts with the submission pipeline (submitParkCreation → approve → verify), aligning tests with RLS policies and validation flows.
2025-11-10 16:59:10 +00:00
gpt-engineer-app[bot]
20cd434e73 Remove display_name and fix submission_type
Apply Phase 1 and 2 fixes:
- Remove display_name from location objects in approvalTestHelpers.ts
- Update submission_type to park/ride instead of park_create/ride_create
2025-11-10 16:56:22 +00:00
gpt-engineer-app[bot]
3cb0f66064 Make test results copyable
Add Markdown formatting utilities for test results, wire up clipboard copy in IntegrationTestRunner, and export new formatters. Introduce formatters.ts, extend index.ts exports, and implement copy all / copy failed / per-test copy functionality with updated UI.
2025-11-10 16:48:51 +00:00
gpt-engineer-app[bot]
ad31be1622 Combine Testing UIs
Merge Testing and Integration Tests into a single Testing control center in AdminSettings. Remove the separate integration-tests tab, and update the Testing tab to render both Test Data Generator and Integration Test Runner together, with appropriate headers and icons (Database and TestTube). Add Database to imports.
2025-11-10 16:44:31 +00:00
gpt-engineer-app[bot]
68d6690697 Add remaining approval tests
Expand approvalPipelineTests with 12 tests: park/ride updates, composites, photo galleries, edge cases (locks, invalid refs, banned users), and versioning. Include helpers for photo submissions and direct entity creation, plus photo gallery support and invalid temp-ref handling.
2025-11-10 16:39:05 +00:00
gpt-engineer-app[bot]
5169f42e2d Connect to Lovable Cloud
Implement integration plan to connect to Lovable Cloud by adopting the Lovable Cloud toolchain flow:
- Initiate tool-based wiring for Lovable Cloud connectivity
- Set up scaffolding to enable approved workflow and data exchange with Lovable Cloud
- Prepare for secure auth/session handling and API interactions
- Outline groundwork for subsequent implementation steps in the Lovable Cloud integration path
2025-11-10 16:32:28 +00:00
pacnpal
095cd412be Restore approval pipeline with tracing functionality
This migration restores the complete approval pipeline functionality by recreating the process_approval_transaction function and ensuring all entity types are handled correctly.
2025-11-10 10:15:24 -05:00
pacnpal
2731635b4d Merge pull request #13 from pacnpal/main
dev
2025-11-10 10:10:46 -05:00
pacnpal
9a1ecb0663 Merge branch 'dev' into main 2025-11-10 10:10:37 -05:00
pacnpal
00de87924c Restore approval pipeline with tracing functionality
This migration restores the complete approval pipeline functionality by recreating the 'process_approval_transaction' function, which handles the approval process for various entity types. It also includes tracing capabilities for monitoring the approval process.
2025-11-10 10:08:07 -05:00
gpt-engineer-app[bot]
236e412d7c Connect to Lovable Cloud 2025-11-10 14:55:58 +00:00
gpt-engineer-app[bot]
fce582e6ba Consolidate Admin Logs Hub
- Implement new unified monitoring hub by adding EdgeFunctionLogs, DatabaseLogs, CorrelatedLogsView, and UnifiedLogSearch components
- Integrate new tabs (edge-functions, database, traces) into ErrorMonitoring and expose TraceViewer route
- Update admin sidebar link to reflect Monitoring hub and extend error modals with log-correlation actions
- Wire up app to include trace viewer route and adjust related components for unified log correlation
2025-11-10 14:49:33 +00:00
gpt-engineer-app[bot]
89338a06ea Connect to Lovable Cloud
Integrate Lovable Cloud tracing updates by enabling distributed tracing in edge functions, adjusting breadcrumb/trace propagation, and preparing RPC span handling. Files touched include edgeFunctionTracking and related RPC tracing scaffolding.
2025-11-10 14:42:39 +00:00
gpt-engineer-app[bot]
96adb2b15e Connect to Lovable Cloud
Implement distributed tracing across edge functions:
- Introduce span types and utilities (logger.ts enhancements)
- Replace request tracking with span-based tracing in approval and rejection flows
- Propagate and manage W3C trace context in edge tracking
- Add span visualization scaffolding (spanVisualizer.ts) and admin TraceViewer UI (TraceViewer.tsx)
- Create tracing-related type definitions and support files
- Prepare RPC call logging with span context and retries
2025-11-10 14:40:44 +00:00
gpt-engineer-app[bot]
1551a2f08d Add structured moderation logging
Enhance edge functions process-selective-approval and process-selective-rejection with edgeLogger-based, structured logging. Introduce request tracking (startRequest/endRequest), replace all console logs, add comprehensive logging points (auth, payload validation, idempotency, RPC calls, deadlocks, errors, locks), and register process-selective-rejection in config.toml. Also sanitize sensitive data in logs and ensure duration metrics are captured.
2025-11-10 14:32:37 +00:00
gpt-engineer-app[bot]
94312c8ef0 Connect to atomic rejection flow
Introduce atomic rejection for bulk submissions, remove dead moderation code, and clean exports:
- Replace direct DB updates in rejectSubmissionItems with atomic process-selective-rejection edge function call
- Add edge function invocation helper import
- Remove obsolete moderation actions (approvePhotoSubmission, rejectSubmissionItems, performModerationAction) and prune exports
- Update moderation index exports accordingly
- Ensure cascade handling uses atomic pipeline and avoid updateSubmissionStatusAfterRejection calls
2025-11-10 14:19:49 +00:00
gpt-engineer-app[bot]
c7bdff313a Move photo logic to RPC path
Refactor: remove duplicate photo handling from useModerationActions.ts and ensure all photo approvals flow through the atomic process_approval_transaction path. This includes deleting the direct DB update block for photos and relying on the unified approval flow through the edge function. Also note required npm install for package-lock.json.
2025-11-10 14:01:34 +00:00
gpt-engineer-app[bot]
d5974440a5 Remove temp_location_data reference from create_submission_with_items
Fix critical migration bug by dropping and recreating create_submission_with_items to stop referencing deleted temp_location_data; ensure location data uses park_submission_locations table. Notify manually update package-lock.json.
2025-11-10 13:54:30 +00:00
gpt-engineer-app[bot]
6c03a5b0e7 Implement rejection bulletproofing
Created atomic rejection edge function process-selective-rejection and RPC, updated moderation client to use it, and ensured resilience; added CORS wrapper. Reminder: generate package-lock.json by running npm install.
2025-11-10 13:26:13 +00:00
gpt-engineer-app[bot]
92b5d6e33d Implement bulletproof rejection flow
- Adds atomic rejection transaction edge function and RPC
- Updates moderation client to use new rejection path
- Introduces rejection transaction migration and supporting readouts
- Moves photo-related approval handling toward RPC-based flow
- Lays groundwork for idempotency and resilience in moderation actions
2025-11-10 13:20:16 +00:00
pacnpal
a0f6c371fc Merge pull request #12 from pacnpal/django-backend
Django backend
2025-11-08 15:35:05 -05:00