rochel3R
Convex Community2y ago
12 replies
rochel3

pyTelegrambotAPI with convex, cant get image to be sent sometimes

I have a telegram bot that disperses information on seating areas of schools, when queried, it will send an image.
I store the images in convex file system and retrieve the images using the following function

export const getImg = query({
args: { photoId: v.string() },
handler: async (ctx, { photoId }) => {
return await ctx.storage.getUrl(photoId);
},
});

However, i would occasionally get the error

"A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: wrong file identifier/HTTP URL specified"

for some schools and will only be fixed when i reupload the image and replace the fileId of the school record

a school record looks like this:

mrt_schools: defineTable({
school_name: v.string(),
seating_sector: v.string(),
}).index("by_school_name", ["school_name"])

where seating_sector is the fileId in storage and school_name is the name of the school

How can i prevent this? It doesnt seem to happen on my Nextjs project but only this project

It happens to random schools as well, even after testing some schools, it would throw this error on the tested schools that intially sent the image of the seating sector
Was this page helpful?