Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print an error when index creation fails #4064

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Sep 16, 2024

  1. Print an error when index creation fails

    By adding an invalid index, like this
    
    ```
    diff --git a/api/models/schema/messageSchema.js b/api/models/schema/messageSchema.js
    index 24acf29a..c618a28d 100644
    --- a/api/models/schema/messageSchema.js
    +++ b/api/models/schema/messageSchema.js
    @@ -132,6 +132,8 @@ if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
     messageSchema.index({ createdAt: 1 });
     messageSchema.index({ messageId: 1, user: 1 }, { unique: true });
    
    +messageSchema.index({ foobarbazbar: 1 }, { unique: true });
    +
     /** @type {mongoose.Model<TMessage>} */
     const Message = mongoose.models.Message || mongoose.model('Message', messageSchema);
    
    ```
    
    we will see errors like this
    
    ```
    2024-09-16 09:45:01 error: Failed to create Message index MongoServerError: Index build failed: d5bfca52-6ace-48d7-9d3f-906b32f9ff7a: Collection LibreChat.messages ( 29a855ee-abf3-4d7a-abb2-7310628dc011 ) :: caused by :: E11000 duplicate key error collection: LibreChat.messages index: foobarbazbar_1 dup key: { foobarbazbar: null }
    ```
    russell committed Sep 16, 2024
    Configuration menu
    Copy the full SHA
    989543e View commit details
    Browse the repository at this point in the history