Back

Server Error Creating a document

  • 2
  • Databases
  • Web
  • Cloud
Ali Memon
28 Sep, 2023, 16:41
TypeScript
AppwriteException {
  name: 'AppwriteException',
  code: 500,
  type: 'general_unknown',
  response: {
    message: 'Server Error',
    code: 500,
    type: 'general_unknown',
    version: '0.11.4'
  },
  stack: 'AppwriteException: Server Error\n' +
    '    at Client.eval (webpack-internal:///(app-client)/./node_modules/appwrite/dist/esm/sdk.js:410:27)\n' +
    '    at Generator.next (<anonymous>)\n' +
    '    at fulfilled (webpack-internal:///(app-client)/./node_modules/appwrite/dist/esm/sdk.js:41:58)',
  message: 'Server Error'
}

getting this error when creating a new document. was working fine till now.

Function that creates the trip defined in zustand store

TypeScript
createTrip: async (trip) => {
      try {
        let file: Image | undefined;

        if (trip.image) {
          const fileUploaded = await uploadImage(trip.image, process.env.NEXT_PUBLIC_TRIP_BANNER_IMAGE_BUCKET_ID!);
          if (fileUploaded) {
            file = {
              bucketId: fileUploaded.bucketId,
              fileId: fileUploaded.$id,
            };
          }
        }

        const response = await databases.createDocument(
          process.env.NEXT_PUBLIC_TRIPARCHITECT_DATABASE_ID!,
          process.env.NEXT_PUBLIC_TRIPS_COLLECTION_ID!,
          ID.unique(),
          {
            name: trip.name,
            startDate: trip.startDate,
            endDate: trip.endDate,
            creator: trip.creator,
            ...(file && { image: JSON.stringify(file) }),
          }
        );
        
        return response as Models.Document;

      } catch (error) {
        console.log(error);
      } finally {
        set(() => ({
          isOpen: false,
          imageFile: null,
          tripName: "",
          tripStartDate: "",
          tripEndDate: "",
        }));
      }
    },
TL;DR
User is experiencing a server error when attempting to create a new document in a collection. The error was not present before and REST works for the collection but not the Web SDK. Removing a particular relation allows the creation to work again. Self-hosted users are also experiencing the same issue. The error message received is "Server Error" with a code of 500. The user provides the code and function that creates the trip. No solution is provided in the thread.
Drake
28 Sep, 2023, 17:18

what's your project ID?

WuGGu
29 Sep, 2023, 09:48

Same Problem by me with self hosted. All other collections work.

WuGGu
29 Sep, 2023, 10:15

Funny thing, REST works for this collection but not the Web SDK.

WuGGu
29 Sep, 2023, 11:44

@Ali Memon did you add a relation to your collection. After I removed the relation it works again. I added One Way and Two Way relations. Even if I not use them in the create process because they are not required it works. But as soon I want to touch them I get a 500 error. @Steven What kind of logs should I create for an Issue about this, that would help you to check this?

Drake
29 Sep, 2023, 23:00

exact reproducible steps and, if you're self hosting, docker logs from the appwrite container for the related API call

PingGhost
29 Sep, 2023, 23:07

same issue on cloud

PingGhost
29 Sep, 2023, 23:09

/v1/account fail also with 500

Ali Memon
30 Sep, 2023, 04:26

can you explain a bit more? @WuGGu

Ali Memon
30 Sep, 2023, 04:27

6475c7f6bc7e095dae62

WuGGu
30 Sep, 2023, 07:32

I have a collection called projects and have relations to the collection data and sessions. Now I added a collection called mapping which has a relation to projects but also data and session. After I removed the data and session relation out of mapping it works again. as soon I add the relation and want to use them by creating a relation with ID with the Web SDK I get a 500 Error.

data --> projects <-- session | projects <--mapping | data --> mapping <-- session | The last relation kills it.

Ali Memon
30 Sep, 2023, 07:38

In my case, I have a single collection called trips that's it. There are no relations

Drake
30 Sep, 2023, 18:03

did you used to?

Drake
30 Sep, 2023, 18:03

are you still having this problem?

Drake
30 Sep, 2023, 18:05

Server Error Creating a document

Ali Memon
1 Oct, 2023, 08:06

No The databases structure was not modified It was working fine till the previous week

Ali Memon
1 Oct, 2023, 08:07

Yes, In my case when creating a trip I am doing two things 1. Create a storage file and get the file Id 2. Create a new document in trips collection

Drake
1 Oct, 2023, 17:30

Did you change your schema at all?

Ali Memon
3 Oct, 2023, 15:54

No

Drake
3 Oct, 2023, 19:43

something seems screwed up with your collection...can you recreate it?

Ali Memon
4 Oct, 2023, 18:41

Ok I will try doing that

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