Files
ebaysnipeextension/APPWRITE_USERID_ATTRIBUTE_FIX.md
Kenso Grimm 216a972fef chore: initialize project repository with core extension files
- Add .gitignore to exclude node_modules, dist, logs, and system files
- Add comprehensive project documentation including README, deployment guide, and development setup
- Add .kiro project specifications for amazon-product-bar-extension, appwrite-cloud-storage, appwrite-userid-repair, blacklist-feature, and enhanced-item-management
- Add .kiro steering documents for product, structure, styling, and tech guidelines
- Add VSCode settings configuration for consistent development environment
- Add manifest.json and babel/vite configuration for extension build setup
- Add complete source code implementation including AppWrite integration, storage managers, UI components, and services
- Add comprehensive test suite with Jest configuration and 30+ test files covering all major modules
- Add test HTML files for integration testing and validation
- Add coverage reports and build validation scripts
- Add AppWrite setup and repair documentation for database schema management
- Add migration guides and responsive accessibility implementation documentation
- Establish foundation for Amazon product bar extension with full feature set including blacklist management, enhanced item workflows, and real-time synchronization
2026-01-12 17:46:42 +01:00

5.8 KiB

🔧 AppWrite userId Attribute Fix - Step by Step

Current Problem

Your AppWrite collections are missing the critical userId attribute. The error logs show:

Invalid query: Attribute not found in schema: userId

This happens because the extension tries to filter data by userId but the collections don't have this attribute.

Quick Fix Solution

Step 1: Access Your AppWrite Console

  1. Go to: https://appwrite.webklar.com
  2. Login with your credentials
  3. Select project: 6963df38003b96dab5aa
  4. Navigate to: Databases → amazon-extension-db

Step 2: Add userId Attribute to Each Collection

You need to add the userId attribute to all 5 collections:

Collection 1: amazon-ext-enhanced-items

  1. Click on amazon-ext-enhanced-items
  2. Go to "Attributes" tab
  3. Click "Create Attribute"
  4. Select "String"
  5. Enter:
    • Key: userId
    • Size: 255
    • Required: Yes
    • Array: No
  6. Click "Create"

Collection 2: amazon-ext-saved-products

  1. Click on amazon-ext-saved-products
  2. Go to "Attributes" tab
  3. Click "Create Attribute"
  4. Select "String"
  5. Enter:
    • Key: userId
    • Size: 255
    • Required: Yes
    • Array: No
  6. Click "Create"

Collection 3: amazon_ext_blacklist

  1. Click on amazon_ext_blacklist
  2. Go to "Attributes" tab
  3. Click "Create Attribute"
  4. Select "String"
  5. Enter:
    • Key: userId
    • Size: 255
    • Required: Yes
    • Array: No
  6. Click "Create"

Collection 4: amazon-ext-enhanced-settings

  1. Click on amazon-ext-enhanced-settings
  2. Go to "Attributes" tab
  3. Click "Create Attribute"
  4. Select "String"
  5. Enter:
    • Key: userId
    • Size: 255
    • Required: Yes
    • Array: No
  6. Click "Create"

Collection 5: amazon-ext-migration-status

  1. Click on amazon-ext-migration-status
  2. Go to "Attributes" tab
  3. Click "Create Attribute"
  4. Select "String"
  5. Enter:
    • Key: userId
    • Size: 255
    • Required: Yes
    • Array: No
  6. Click "Create"

Step 3: Fix Permissions (Critical!)

After adding userId attributes, you must fix permissions for each collection:

For EACH collection:

  1. Click on the collection name

  2. Go to "Settings" tab (not "Attributes")

  3. Scroll down to "Permissions" section

  4. Set these exact permissions:

    Create Permission:

    • Click "Add a permission"
    • Select: users
    • Click "Add"

    Read Permission:

    • Click "Add a permission"
    • Select: user:$userId
    • Click "Add"

    Update Permission:

    • Click "Add a permission"
    • Select: user:$userId
    • Click "Add"

    Delete Permission:

    • Click "Add a permission"
    • Select: user:$userId
    • Click "Add"
  5. Click "Update" to save

Step 4: Test the Fix

  1. Reload your Chrome extension
  2. Go to Amazon: https://amazon.de/s?k=smartphone
  3. Open browser console (F12)
  4. Check for errors - should see no more "userId" errors
  5. Test Enhanced Items - should work without errors

Expected Results After Fix

Console should show:

✅ AppWrite connection successful
✅ Collections accessible
✅ Real-time sync working
✅ No more "Invalid query: Attribute not found in schema: userId" errors

Extension should work:

  • Enhanced Items panel opens
  • Items can be saved to AppWrite
  • Data appears in AppWrite console
  • Real-time sync between tabs

Visual Guide 📸

Finding the Attributes Tab:

AppWrite Console
└── Databases
    └── amazon-extension-db
        └── [Collection Name] ← Click here
            ├── Documents
            ├── Attributes ← Go here to add userId
            └── Settings ← Go here for permissions

Adding userId Attribute:

Attributes Tab
└── Create Attribute
    ├── Type: String ← Select this
    ├── Key: userId ← Enter this
    ├── Size: 255 ← Enter this
    ├── Required: ✅ ← Check this
    └── Array: ❌ ← Leave unchecked

Setting Permissions:

Settings Tab
└── Permissions Section
    ├── Create: users ← Any authenticated user can create
    ├── Read: user:$userId ← Users can only read their own data
    ├── Update: user:$userId ← Users can only update their own data
    └── Delete: user:$userId ← Users can only delete their own data

Troubleshooting 🔧

Still getting "userId" errors?

  1. Make sure you added userId to ALL 5 collections
  2. Check that userId is marked as "Required"
  3. Verify the attribute name is exactly userId (case-sensitive)
  4. Clear browser cache and reload extension

Still getting 401 permission errors?

  1. Make sure permissions are set correctly for ALL collections
  2. Use user:$userId not just users for Read/Update/Delete
  3. Try logging out and back in to the extension

Collections not found?

  1. Make sure you're in the right project: 6963df38003b96dab5aa
  2. Check database name: amazon-extension-db
  3. Collection names must match exactly (case-sensitive)

Alternative: Use Test Tool 🧪

Open this file in your browser to automatically test your collections:

  • test-appwrite-collections.html

This will tell you exactly which collections are missing the userId attribute.

Why This Happened 🤔

The collections were created without the userId attribute, but the extension code expects it to exist for:

  • Data isolation: Each user only sees their own data
  • Security: Prevents users from accessing other users' data
  • Filtering: All queries filter by userId to get user-specific data

Adding the userId attribute and setting proper permissions fixes this issue permanently.