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

[BUG] REST API search on recipes is not case insensitive #5157

Closed
6 tasks done
wsargent opened this issue Mar 2, 2025 · 1 comment · Fixed by #5162
Closed
6 tasks done

[BUG] REST API search on recipes is not case insensitive #5157

wsargent opened this issue Mar 2, 2025 · 1 comment · Fixed by #5162
Labels
bug: confirmed bug Something isn't working

Comments

@wsargent
Copy link

wsargent commented Mar 2, 2025

First Check

  • This is not a feature request.
  • I added a very descriptive title to this issue (title field is above this).
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Mealie documentation, with the integrated search.
  • I already read the docs and didn't find an answer.
  • This issue can be replicated on the demo site (https://demo.mealie.io/).

What is the issue you are experiencing?

When using the REST API to find recipes with given keywords, the LIKE term is case sensitive. This leads to unexpected results if the wrong case is used.

Steps to Reproduce

import requests
import os
import json

import requests
import os

from urllib.parse import urljoin

def find_recipes_in_mealie(searchTerm: str) -> str:
    base_url = os.getenv("MEALIE_ENDPOINT")
    api_key = os.getenv("MEALIE_API_KEY")
    headers = {
        "accept": "application/json",
        "Authorization": "Bearer " + api_key
    }

    endpoint = urljoin(base_url, '/api/recipes')
    params = {
        "queryFilter": = f"name LIKE \"%{searchTerm}%\""
    }
    
    response = requests.get(endpoint, headers=headers, params=params)
    response.raise_for_status()
    
    recipes_json = response.json()
    items = recipes_json["items"]
    if (len(items) == 0):
        return "No recipes found"
    return items

def main():
    try:
        recipes = find_recipes_in_mealie("chili") # no results
        recipes = find_recipes_in_mealie("Chili") # found results
    except requests.exceptions.HTTPError as e:
        print(f"Error: {e.response.status_code} - {e.response.text}")

if __name__ == "__main__":
    main()

Please provide relevant logs

Not applicable

Mealie Version

Build
2d73c703cb8ee192467adb41bbfc1a714a22a819

Deployment

Docker (Linux)

Additional Deployment Details

No response

@wsargent wsargent added bug Something isn't working triage labels Mar 2, 2025
@michael-genson
Copy link
Collaborator

Interestingly in SQLite LIKE is case-insensitive. Postgres has LIKE and ILIKE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: confirmed bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants