aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
89 stars 77 forks source link

Issue with Index Creation in Amazon Amplify Backend #2484

Closed FrancescBagur closed 4 months ago

FrancescBagur commented 6 months ago

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v20.9.0

Amplify CLI Version

12.11.1

What operating system are you using?

Ubuntu

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Describe the bug

I have noticed that sometimes, when saving a recipe, the corresponding index is not created successfully. Here is an example of the entity type Recipe that I am using:

type Recipe @model @searchable @auth(rules: [{ allow: owner }, { allow: public, operations: [read] }]) { id: ID! typeIndex: String! @index(name: "recipeByDate", queryField: "recipeByDate", sortKeyFields: ["createdAt"]) createdAt: String! slug: ID! @index title: String description: String image: String }

In this schema, the field "slug" is indexed for efficient search. However, in some cases, after saving a recipe, I am unable to retrieve it using the "bySlug" index.

This issue is affecting the functionality of my application and is causing inconvenience to our users. We rely on the index creation to ensure smooth retrieval of recipe data.

Could you please investigate this issue and provide guidance on how to ensure consistent index creation for the "slug" field?

Thank you for your attention to this matter. If you require any further information or clarification, please do not hesitate to reach out.

Best regards,

Expected behavior

I espect the indexes are not lost

Reproduction steps

I don't know, the users have created more than 100 recipes and it works well but now, to recipes had loose the index.

Project Identifier

No response

Log output

``` # Put your logs below this line ```

Additional information

No response

Before submitting, please confirm:

biller-aivy commented 6 months ago

What do you mean with lost their index? You can't find it by DynamoDB console or only by GraphQL?

Try to find per dynamodb console, just to be sure this is not related to an other issue with some Auth problems.

FrancescBagur commented 6 months ago

Dear team,

I have applied the "@searchable" directive to our recipe entities. However, I have noticed that these particular recipes are not appearing in the results when using the "listRecipe" query, nor are they retrieved when using any key in the query. Strangely, I am able to locate these recipes successfully using the "searchRecipe" query.

Upon inspecting the database table via the Amazon Web Console, I can confirm that the records for these recipes do exist. The only workaround I have found to retrieve these missing recipes is by duplicating the record and deleting the original. It seems as though the indexes associated with these recipes are somehow being lost or corrupted.

This issue has occurred twice now, despite having a large number of recipes in our database, and it is causing significant concern. I would greatly appreciate your assistance in investigating and resolving this matter promptly.

Thank you for your attention to this issue. Please let me know if you require any further information or clarification.

FrancescBagur commented 6 months ago

Here we go again, I have another recipe without an index. It's a recipe that hasn't been edited for a long time and has always worked. The issue is very serious...

biller-aivy commented 6 months ago

Here we go again, I have another recipe without an index. It's a recipe that hasn't been edited for a long time and has always worked. The issue is very serious...

So you are using the searchable or the graphql query?

phani-srikar commented 6 months ago

Hi @FrancescBagur, did you change the type of slug from being optional to a required when adding that index? Can you post some examples of items that you're able to query but not list? Also, when you query, is the current user also the owner of the missing item? It could be that the client is signed-in as a cognito user and doesn't own the records that you're claiming as missing.

FrancescBagur commented 6 months ago

Hi @phani-srikar,

Yes, the slug is required. And the item have public access to read operations:

type Recipe @model @searchable @auth(rules: [{ allow: owner }, { allow: public, operations: [read] }]) { id: ID! typeIndex: String! #Siempre se tiene que informar como "recipe" y nos sirve para crear el índice y ordenar por fecha. @index(name: "recipeByDate", queryField: "recipeByDate", sortKeyFields: ["createdAt"]) createdAt: String! slug: ID! @index title: String description: String image: String diners: Int ..... }

Anyway, if it were a permissions error, it would throw an error when querying. Right now, I don't have any item that could trigger it because with the ones that did, I duplicated them and deleted the original, and it worked fine again. It hasn't happened to me for a few days, but just when it happened again, I'll send you an example. Thank you very much for the help, regards.

AnilMaktala commented 4 months ago

Hey 👋 , This issue is being closed due to inactivity. If you are still experiencing the same problem and need further assistance, please feel free to leave a comment. This will enable us to reopen the issue and provide you with the necessary support.

github-actions[bot] commented 4 months ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.