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

MeiliSearch::Rails::MSCleanUpJob 404 error when deleting records #352

Closed
drale2k opened this issue Apr 20, 2024 · 3 comments · Fixed by #353
Closed

MeiliSearch::Rails::MSCleanUpJob 404 error when deleting records #352

drale2k opened this issue Apr 20, 2024 · 3 comments · Fixed by #353
Labels
bug Something isn't working

Comments

@drale2k
Copy link

drale2k commented Apr 20, 2024

Description
When i delete a record in my rails app which has meilisearch indexing set up, the background job fails with the following error:
Error: MeiliSearch::ApiError: 404 Not Found - MeiliSearch API has not returned any error message. See <no documentation link found>.

Arguments:
[{"index_uid"=>nil, "primary_key"=>"45", "synchronous"=>nil, "_aj_hash_with_indifferent_access"=>true}]

For some reason index_uid is nil and it cannot find the record. My model setup is pretty straight forward

class Episode < ApplicationRecord
  include MeiliSearch::Rails

  ...

  meilisearch enqueue: true do
    attributes :title, :body

    attribute(:categories) { video.categories.pluck(:name) }
    attribute(:published_at) { published_at&.to_i }

    searchable_attributes [ :title, :body ]
    filterable_attributes [ :categories ]
    sortable_attributes [ :created_at ]

    attributes_to_highlight [ "*" ]
    attributes_to_crop [ :description, :transcript ]
    crop_length 50
  end
end

Expected behavior
The document to be deleted from the Meilisearch Index

Current behavior
Error explained above

Screenshots or Logs
If applicable, add screenshots or logs to help explain your problem.

Environment (please complete the following information):

  • OS: Development ENV on macOS
  • Meilisearch server version: Meilisearch Cloud (latest)
  • meilisearch-rails version: v0.12.0
  • Rails version: v7.1
@drale2k
Copy link
Author

drale2k commented Apr 20, 2024

The error only seems to occur when enqueue is set to true and meilisearch spawns a bg job for the deletion. If i set to enqueue: false it works. This is annoying as i need to queue meilisearch operations to the background to not block the app workers

ellnix added a commit to ellnix/meilisearch-rails that referenced this issue Apr 20, 2024
ellnix added a commit to ellnix/meilisearch-rails that referenced this issue Apr 20, 2024
@ellnix
Copy link
Collaborator

ellnix commented Apr 20, 2024

Thanks for the bug report @drale2k

I believe I found the bug (and I found that I was the one responsible for it 😭 ), could you please try #353 ? Only one line is changed.

@drale2k
Copy link
Author

drale2k commented Apr 20, 2024

@ellnix Thanks a lot for the quick response and fix. I can confirm the PR works

@curquiza curquiza added the bug Something isn't working label Apr 22, 2024
meili-bors bot added a commit that referenced this issue Apr 22, 2024
353: Fix missing index_uid in clean up job (#352) r=curquiza a=ellnix

# Pull Request

## Related issue
Fixes #352


Co-authored-by: ellnix <103502144+ellnix@users.noreply.github.com>
meili-bors bot added a commit that referenced this issue Apr 29, 2024
353: Fix missing index_uid in clean up job (#352) r=curquiza a=ellnix

# Pull Request

## Related issue
Fixes #352


Co-authored-by: ellnix <103502144+ellnix@users.noreply.github.com>
ellnix added a commit to ellnix/meilisearch-rails that referenced this issue Apr 30, 2024
brunoocasali added a commit that referenced this issue May 7, 2024
Fix missing index_uid in clean up job (#352)
meili-bors bot added a commit that referenced this issue May 10, 2024
357: Update version for the next release (v0.13.0) r=brunoocasali a=ellnix

We should ship the fix to #352 ASAP, and also add support for #351, I believe that would mean a minor version in semver.

Co-authored-by: ellnix <103502144+ellnix@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants