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

Custom filtering triggers invalid query #3154

Open
sunech opened this issue Jan 4, 2025 · 0 comments
Open

Custom filtering triggers invalid query #3154

sunech opened this issue Jan 4, 2025 · 0 comments
Labels
bug Something isn't working fixed in dev Fixed in the dev branch

Comments

@sunech
Copy link

sunech commented Jan 4, 2025

Describe the Bug

When adding a filter and not selecting one of the predefined values, but rather searching for a specific country for example, the API returns 401 Unauthorized.

According to the logs, it appears this is triggered by an invalid query including {{search} instead of {{search}}

Endpoint: /api/websites/6e8f02ae-d893-4d39-abeb-e132fb8d1585/values?type=country&startAt=1735898400000&endAt=1735984799999&search=AE%2CGB%2CUS
Response: 401 Unauthorized

Database

PostgreSQL

Relevant log output

2025-01-03T23:21:55.694142465Z     select country as "value", count(*)
2025-01-03T23:21:55.694144479Z     from website_event
2025-01-03T23:21:55.694146353Z     inner join session
2025-01-03T23:21:55.694148187Z       on session.session_id = website_event.session_id
2025-01-03T23:21:55.694150111Z     where website_event.website_id = {{websiteId::uuid}}
2025-01-03T23:21:55.694152144Z       and website_event.created_at between {{startDate}} and {{endDate}}
2025-01-03T23:21:55.694154118Z       and country ilike {{search}
2025-01-03T23:21:55.694155952Z     group by 1
2025-01-03T23:21:55.694157775Z     order by 2 desc
2025-01-03T23:21:55.694159629Z     limit 10
2025-01-03T23:21:55.694161452Z     
2025-01-03T23:21:55.694166582Z 2025-01-03T23:21:55.693Z umami:prisma PARAMETERS:
2025-01-03T23:21:55.694168776Z  {
2025-01-03T23:21:55.694170719Z   websiteId: '6e8f02ae-d893-4d39-abeb-e132fb8d1585',
2025-01-03T23:21:55.694172603Z   startDate: 2025-01-03T00:00:00.000Z,
2025-01-03T23:21:55.694174466Z   endDate: 2025-01-03T23:59:59.999Z,
2025-01-03T23:21:55.694176330Z   search: '%SE%'
2025-01-03T23:21:55.694178193Z }
2025-01-03T23:21:55.695550200Z Error [PrismaClientKnownRequestError]: 
2025-01-03T23:21:55.695573264Z Invalid `prisma.$queryRawUnsafe()` invocation:
2025-01-03T23:21:55.695575829Z 
2025-01-03T23:21:55.695577783Z 
2025-01-03T23:21:55.695579727Z Raw query failed. Code: `42601`. Message: `ERROR: syntax error at or near "{"

Which Umami version are you using? (if relevant)

2.15.1

Which browser are you using? (if relevant)

Tested in Chrome and Firefox

How are you deploying your application? (if relevant)

Docker via Coolify

@mikecao mikecao added bug Something isn't working fixed in dev Fixed in the dev branch labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in dev Fixed in the dev branch
Projects
None yet
Development

No branches or pull requests

2 participants