Skip to content

Fix UI: Persisted project data not fetched/rendered after page reload #26

@arin-gupta06

Description

@arin-gupta06

📌 Summary

Projects are successfully stored in the database but are not displayed in the UI after a page refresh. This results in a mismatch between backend data and frontend state.


📖 Description

When a user creates a project, it is immediately visible in the UI and correctly saved in the database. However, upon refreshing the page, the UI fails to fetch and display the existing projects.

Verification via Supabase dashboard confirms that the data is persisted correctly. The issue appears to be related to data retrieval, authorization (RLS), or frontend rendering logic rather than data insertion.


🔁 Steps to Reproduce

  1. Create a new project via the UI
  2. Observe that the project appears in the list
  3. Open Supabase → confirm the project row exists in projects table
  4. Refresh the page
  5. Observe that the project is no longer visible in the UI

✅ Expected Behavior

  • Projects stored in the database should be fetched on page load
  • UI should consistently reflect the current database state

❌ Actual Behavior

  • Project data is stored successfully in DB ✅
  • UI does not display projects after refresh ❌

🔍 Investigation / Observations

  • Insert operation works as expected
  • Issue occurs specifically during data fetching after reload
  • Likely tied to authentication context or RLS restrictions

⚠️ Possible Root Causes

  • Row Level Security (RLS) blocking SELECT queries
  • Missing or incorrect SELECT policy (auth.uid() = owner_id)
  • owner_id not matching authenticated user
  • User session not initialized before fetch call
  • Fetch logic not triggered on component mount / page load
  • API route or Supabase client misconfiguration

🛠️ Suggested Fix / Checks

Ensure the following Supabase configuration:

-- Enable RLS
alter table projects enable row level security;

-- Insert policy
create policy insert_own_project on projects
for insert
with check (auth.uid() = owner_id);

-- Select policy
create policy select_own_projects on projects
for select
using (auth.uid() = owner_id);

Additional checks:

  • Ensure owner_id is set using auth.uid() during insert
  • Verify user authentication state before fetching data
  • Confirm fetch is executed on page load (client/server)
  • Check network tab for failed or empty responses
  • Avoid duplicate or conflicting policies

🧪 Environment

  • Frontend: (e.g., Next.js / React)
  • Backend: Supabase
  • Database: PostgreSQL

📎 Evidence (Optional)

  • Screenshots of DB records
  • Network request logs
  • Console errors

🚀 Impact

High — affects core functionality (data visibility and user trust)


💡 Notes

This is not a persistence issue. Data is correctly stored but not retrieved or rendered, indicating a problem in the read flow (auth → query → UI state).

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions