The error Uncaught Error: Index users.email not found. means that your Convex schema is missing an index on the email field of your users table. Convex Auth and related account linking logic require this index to efficiently look up users by email.
How to fix:
- Add the index to your schema:
In your convex/schema.ts, ensure your users table includes an index on the email field. For example:
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";
export default defineSchema({
users: defineTable({
email: v.string(),
}).index("email", ["email"]),
});
If you are using the default authTables from Convex Auth, you can override the users table to add the index:
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";
import { authTables } from "@convex-dev/auth/server";
const schema = defineSchema({
...authTables,
users: defineTable({
email: v.optional(v.string()),
}).index("email", ["email"]),
});
export default schema;
See more details here
- Deploy your schema changes:
After updating your schema, run:
npx convex dev
or
npx convex deploy
This will apply the schema changes and create the required index.
Note: You must define the index exactly as shown (.index("email", ["email"])). If you already have an index but with a different name or fields, Convex Auth will not find it and will throw this error.