Back

Help : Suddenly my website is showing this error

  • 0
  • Databases
  • Web
  • Cloud
LAKSHYA
26 Apr, 2024, 15:17

AppwriteException: Invalid query: Cannot query search on attribute "tags" because it is an array.

why? because everything is working fine. how to solve it because my website is in the production

this is my code async searchResultsBytags(tag: string) { try { return await this.databases.listDocuments( conf.appwriteDatabaseId, conf.appwriteCollectionId, [ Query.orderDesc("$createdAt"), Query.select(["title","$id"]), Query.equal("tags", "${tag}"), Query.equal("status", "Approved"), // Add this condition Query.limit(8), ] ); } catch (error) { console.error("appwrite service :: CategoryBegginersInfo 3 :: ", error); return false; } }

TL;DR
Website showed an error due to an SDK issue. An app fix is underway, use Query.contains() for array attributes. Upgrade to Appwrite SDK 14.0.1 and make changes in query method. The issue is related to the array attribute ‘tags’. Appwrite Console may help to resolve.
Meldiron
26 Apr, 2024, 15:21

Hello there 👋 This may be coming from our end, allow me few minutes to check it please 🙏

Meldiron
26 Apr, 2024, 15:23

Can you please do me a favour? If you visit Appwrite Console and look at attributes tab of your collection, what type&length is the tags attribute? Also, can you please provide me some sample value of any of your documents? To better imagine the situation

Steven
26 Apr, 2024, 15:23

Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting

Steven
26 Apr, 2024, 15:24

Where's the search query? 🧐

Meldiron
26 Apr, 2024, 15:24

I think it's equal on array attributes that also cause trouble. Need to verify

LAKSHYA
26 Apr, 2024, 15:35
LAKSHYA
26 Apr, 2024, 15:35

length is 255

Meldiron
26 Apr, 2024, 15:36

Thank you so much for confirming 🙏 Let's see if this fixes it:

  1. In your App, upgrade to latest Appwrite SDK. For web, that is npm install appwrite@14.0.1
  2. Switch from:
TypeScript
Query.equal("tags"...

to:

TypeScript
Query.contains("tags", tag)
LAKSHYA
26 Apr, 2024, 15:37

okay let me check

LAKSHYA
26 Apr, 2024, 15:47

thanks a lot . it worked

Meldiron
26 Apr, 2024, 15:48

Amazing. Sorry for the trouble; we will add a fix to prevent this sudden error. Query.contains() is intentional, so you can feel safe with this implemented 🙌

LAKSHYA
26 Apr, 2024, 15:57

wait

LAKSHYA
26 Apr, 2024, 15:58

now its giving me this error

LAKSHYA
26 Apr, 2024, 15:58

Type error: Property 'createEmailSession' does not exist on type 'Account'. Did you mean 'createSession'? 60 | async login({ email, password }: LoginUserAccont) { 61 | try {

62 | return await account.createEmailSession(email, password); | ^ 63 | } catch (error: any) { 64 | throw error; 65 | } Error: Command "npm run build" exited with 1

LAKSHYA
26 Apr, 2024, 15:58

on build

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more