🔧 CHEAT SHEET: TROUBLESHOOTING GUIDE powered by eMOBIQ AI

Quick Fixes for Common Problems


🎯 THE TROUBLESHOOTING PROCESS

1. IDENTIFY → What's wrong? (Expected vs Actual)
2. DIAGNOSE → Why did it happen? (Root cause)
3. FIX → Write clear prompt to resolve
4. TEST → Verify it works
5. LEARN → Remember for next time

⚠️ COMMON ISSUE #1: BUTTON DOES NOTHING

Symptoms

  • ✗ Click button
  • ✗ No response
  • ✗ No error
  • ✗ No visual feedback

Quick Check

  1. Open browser console (F12)
  2. Click button
  3. Look for errors

Fix Prompt

The [BUTTON_NAME] button is not responding.

Expected behavior:
- When clicked, should [EXPECTED_ACTION]

Current behavior:
- Nothing happens

Fix needed:
1. Ensure button has click event handler
2. Verify handler triggers correct function
3. Add console log: "Button clicked"
4. Add loading indicator while processing
5. Show success/error message after action
6. Handle any errors gracefully

Test: Click button, check console log appears

Prevention

Always include in original prompt:

When [BUTTON] is clicked:
1. Show loading state
2. Perform [ACTION]
3. Show success/error feedback
4. Log to console for debugging

⚠️ COMMON ISSUE #2: FORM SUBMITS WITH EMPTY FIELDS

Symptoms

  • ✗ Can submit with required fields empty
  • ✗ Bad data gets saved
  • ✗ No validation errors show

Quick Check

  • Try submitting empty form
  • Check if validation rules exist
  • Look for error messages

Fix Prompt

Form validation is not preventing empty submissions.

Required fields:
- [FIELD_1]: cannot be empty
- [FIELD_2]: must be valid email
- [FIELD_3]: minimum 2 characters

Fix validation:
1. Check each required field on submit
2. If any invalid: show errors, prevent submit
3. Display error below each field in red
4. Error messages:
   - "[Field] is required"
   - "[Field] must be valid email"
5. Clear error when user fixes input
6. Disable submit button until all fields valid

Test: Try submitting empty form, should see errors

Prevention

Validation rules:
- [FIELD]: [RULE]
- Show errors below fields
- Prevent submit if invalid
- Disable button until valid

⚠️ COMMON ISSUE #3: DATA DOESN’T PERSIST

Symptoms

  • ✗ Add data, appears in list
  • ✗ Refresh page, data gone
  • ✗ Changes don’t save

Quick Check

  1. Add data
  2. Open browser DevTools → Application → Local Storage
  3. Check if data is there
  4. Or check Supabase dashboard

For Local Storage

Data not persisting in local storage.

Fix needed:
1. When saving:
   - Use key: "[YOUR_KEY]"
   - Format: JSON.stringify(dataArray)
   - Verify save: localStorage.getItem('key')
   - Log: "Saved: " + data

2. When loading:
   - Use same key: "[YOUR_KEY]"
   - Parse: JSON.parse(storedData)
   - Handle null: use []
   - Log: "Loaded: " + data

3. Ensure:
   - Save happens BEFORE any navigation
   - Load happens AFTER page loads
   - Keys match exactly

Test: Add item, refresh, item should remain

For Supabase

Data not persisting in Supabase.

Debug:
1. Check connection is successful
2. Verify table name is correct
3. Log save operation:
   - "Saving to Supabase: " + data
   - "Response: " + JSON.stringify(result)
4. Check Supabase dashboard for new row

Fix:
1. Verify credentials (URL and key)
2. Check RLS policies allow insert
3. Ensure column names match exactly
4. Handle errors and display to user

Test: Add item, check Supabase dashboard

⚠️ COMMON ISSUE #4: LIST SHOWS NO DATA

Symptoms

  • ✗ Data exists in storage
  • ✗ List is empty or shows “No items”
  • ✗ No error message

Quick Check

  1. Check data exists (console or dashboard)
  2. Look for console errors
  3. Verify fetch is being called

Fix Prompt

List is empty but data exists in [STORAGE].

Debug and fix:
1. Verify data exists:
   - Check [storage] directly
   - Log: "Data in storage: " + JSON.stringify(data)

2. Check fetch operation:
   - Log: "Fetching data..."
   - Log result: "Fetched X items"
   - Verify fetch completes

3. Check display logic:
   - Log before rendering: "Rendering X items"
   - Verify items array is passed to display
   - Check template/mapping is correct

4. Verify data structure:
   - Log first item: data[0]
   - Check field names match
   - Ensure data is array, not object

5. Add proper loading states:
   - Show "Loading..." while fetching
   - Show "No items yet" if truly empty
   - Show error if fetch fails

Show me all console logs.

⚠️ COMMON ISSUE #5: SUPABASE CONNECTION FAILED

Symptoms

  • ✗ “Cannot connect” error
  • ✗ 401/403 error
  • ✗ Network error in console

Quick Check

1. Verify credentials:
   - URL format: https://xxxxx.supabase.co
   - Key format: starts with eyJ
   - No extra spaces

2. Check Supabase dashboard:
   - Is project active?
   - Is table created?
   - Do RLS policies exist?

3. Test in browser:
   - Open Network tab
   - Try connection
   - Check request/response

Fix Prompt

Supabase connection is failing.

Error: [PASTE ERROR MESSAGE]

Fix needed:
1. Verify credentials:
   - URL: [YOUR_URL]
   - Key: [FIRST_10_CHARS]...
   - Both are correct format

2. Test connection:
   - Try simple query: fetch 1 record
   - Log full error if fails
   - Check browser console for CORS

3. Verify RLS policies:
   - Check policies allow public access
   - Or implement authentication

4. Show clear error to user:
   - "Cannot connect to database"
   - "Check internet connection"
   - Provide retry button

Log all connection attempts.

If Still Failing

ESCALATE TO: - IT team (if corporate network) - Check Supabase status page - Review Supabase docs - Ask in workshop forum


⚠️ COMMON ISSUE #6: STYLING LOOKS WRONG

Symptoms

  • ✗ Elements overlapping
  • ✗ Text cut off
  • ✗ Doesn’t fit on mobile
  • ✗ Wrong colors

Quick Check

  1. Test on different screen sizes
  2. Check browser DevTools → Elements
  3. Verify styles are applied

Fix Prompt

Layout issues on [SCREEN]:

Problems:
- [SPECIFIC_ISSUE_1]
- [SPECIFIC_ISSUE_2]

Fix layout:
1. Ensure responsive design:
   - Use flexible widths (%, not px)
   - Test on mobile (375px width)
   - Test on tablet (768px)
   - Test on desktop (1024px+)

2. Fix spacing:
   - Add padding inside containers: 16px
   - Add margins between elements: 12px
   - Ensure nothing touches edges

3. Fix specific issues:
   - [ISSUE_1]: [SOLUTION]
   - [ISSUE_2]: [SOLUTION]

4. Ensure touch targets:
   - Buttons minimum 44x44px
   - Tappable areas large enough
   - Proper spacing between tap targets

Test on actual mobile device if possible.

⚠️ COMMON ISSUE #7: LOADING NEVER STOPS

Symptoms

  • ✗ Spinner keeps spinning
  • ✗ “Loading…” never goes away
  • ✗ Can’t interact with app

Fix Prompt

Loading indicator never disappears.

Fix needed:
1. Ensure loading state managed properly:
   - Set loading = true at START
   - Set loading = false at END
   - Set loading = false on ERROR too!

2. Use try-finally pattern:

try {
  setLoading(true)
  // fetch data
  await fetchData()
  // display data
} catch (error) {
  console.log("Error:", error)
  showError(error)
} finally {
  // ALWAYS runs, even if error
  setLoading(false)
}

3. Add timeout safety:
   - If loading > 30 seconds, hide spinner
   - Show "Taking longer than expected"
   - Provide cancel/retry option

4. Log loading state changes:
   - "Loading started"
   - "Loading completed"
   - "Loading state: " + isLoading

Test: Trigger action, verify spinner disappears

⚠️ COMMON ISSUE #8: DELETE DOESN’T WORK

Symptoms

  • ✗ Click delete
  • ✗ Confirmation shows
  • ✗ Confirm, but item remains

Fix Prompt

Delete function not removing items.

Expected:
- Click delete → confirm → item removed

Current:
- Click delete → confirm → item stays

Fix needed:
1. Verify delete operation:
   - Log: "Deleting item with ID: " + id
   - For local storage: remove from array, save back
   - For Supabase: .delete().eq('id', id)
   - Log result

2. Update display immediately:
   - Remove item from displayed list
   - Don't wait for reload
   - Update count

3. Handle errors:
   - If delete fails, show error
   - Keep item in list if error
   - Log error details

4. Verify storage after delete:
   - Check item actually removed
   - Refresh list from storage

Test: Delete item, check storage/database

⚠️ COMMON ISSUE #9: VALIDATION NOT WORKING

Symptoms

  • ✗ Email validation doesn’t catch bad emails
  • ✗ Can enter invalid data
  • ✗ Error messages don’t show

Fix Prompt

Field validation not working for [FIELD].

Rule: [VALIDATION_RULE]
Example invalid: [EXAMPLE]
Should show: [ERROR_MESSAGE]

Fix validation:
1. Implement check:
   - For email: use email regex or built-in validation
   - For required: check field not empty
   - For length: check string.length
   - For format: use regex pattern

2. Show error clearly:
   - Display below field
   - Red color
   - Clear message
   - Specific to error type

3. Clear error when fixed:
   - When user starts typing
   - Or when field becomes valid

4. Prevent submit if invalid:
   - Check all validations
   - Disable submit button
   - Show which fields are invalid

Test with invalid data, should see error

🆘 WHEN COMPLETELY STUCK

The “Start Over” Approach

I'm stuck with [FEATURE]. Let's start fresh.

Goal: [WHAT_I_WANT]

Current situation:
- [WHAT_EXISTS_NOW]

What works:
- [WORKING_FEATURES]

What doesn't work:
- [SPECIFIC_PROBLEMS]

Please provide step-by-step plan to:
1. Fix current issues
2. Achieve my goal
3. Test it works

The “Simplify” Approach

Let's simplify [FEATURE] to most basic version:

Just need:
- [CORE_REQUIREMENT_1]
- [CORE_REQUIREMENT_2]

Remove all extra features for now.
Once basic version works, we'll add features back one by one.

🔍 DEBUGGING CHECKLIST

Before asking for help, check:

Basic Checks: - [ ] Browser console open (F12) - [ ] Any error messages in red? - [ ] What’s the exact error text?

Data Checks: - [ ] Does data exist in storage? - [ ] Is data in correct format? - [ ] Are field names spelled correctly?

Connection Checks: - [ ] Internet connection working? - [ ] Supabase project active? - [ ] Credentials correct?

Code Checks: - [ ] Did recent change break it? - [ ] Worked before, what changed? - [ ] Can I undo last change?

Prompt Checks: - [ ] Was I specific enough? - [ ] Did I include error handling? - [ ] Did I test edge cases?


📋 DIAGNOSTIC PROMPTS

Universal Debug Prompt

Debug this issue:

Feature: [WHAT_FEATURE]
Problem: [WHAT'S_WRONG]
Expected: [WHAT_SHOULD_HAPPEN]
Actual: [WHAT_HAPPENS]

Add extensive logging:
1. Log when function starts
2. Log all input parameters
3. Log each step of process
4. Log final result
5. Log any errors with full details

Show all logs in console.
Tell me what you find.

Connection Debug

Debug [STORAGE] connection:

Add connection test:
1. Try to connect
2. Log connection status
3. Try simple operation (fetch 1 record)
4. Log operation result
5. Log full error if fails

Show:
- Connection URL (mask sensitive parts)
- First 10 chars of key
- Test result
- Any error details

Tell me results of each step.

🚨 ERROR MESSAGE DECODER

“TypeError: Cannot read property ‘x’ of undefined”

Meaning: Trying to access property of null/undefined Fix: Check if data exists before accessing

Change: data.name
To: data?.name  OR  (data && data.name)

“Network Error” / “Failed to fetch”

Meaning: Can’t reach the server Fix: Check internet, verify URL, check CORS

“401 Unauthorized”

Meaning: Authentication failed Fix: Verify API key/credentials, check expiration

“404 Not Found”

Meaning: Endpoint or resource doesn’t exist Fix: Check URL spelling, verify table name

“23505: duplicate key value”

Meaning: Trying to insert duplicate unique value Fix: Check for existing record first, use update instead


💡 PREVENTION TIPS

Always Include in Prompts

1. Error Handling

Handle errors:
- Catch all errors
- Show user-friendly message
- Log technical details
- Provide retry option

2. Loading States

Show loading indicators:
- While fetching data
- While saving
- While processing
- Disable interactions during

3. User Feedback

Provide feedback:
- Success messages
- Error messages
- Confirmation dialogs
- Progress indicators

4. Validation

Validate inputs:
- Check required fields
- Validate formats
- Show errors clearly
- Prevent bad data

5. Logging

Add console logs:
- Function starts
- Key operations
- Errors
- Results

🎓 LEARNING FROM ERRORS

After Fixing Issue

Document It:

Problem: [WHAT_WAS_WRONG]
Cause: [WHY_IT_HAPPENED]
Solution: [HOW_I_FIXED_IT]
Lesson: [WHAT_I_LEARNED]

Update Your Prompt Library: Save prompts that worked well for future use

Share with Community: Help others avoid same issue


🆘 ESCALATION CRITERIA

When to Ask for Help

Try First (3 attempts): - Rewrite prompt more clearly - Simplify to basic version - Check troubleshooting guide

Escalate If: - Same error after 3 tries - Completely stuck - Critical issue blocking progress - Security concern

What to Include: - Exact error message - What you tried - Screenshots - Steps to reproduce


REMEMBER

🎯 Most issues are communication issues 🔧 Better prompts = fewer problems 📝 Always log for debugging 🔄 Iteration is normal 💪 You can fix this!


Keep this handy for quick reference!

Version 1.0 | eMOBIQ AI Workshop Materials © Orangekloud Technology Inc.