Skip to content

fix: Insights report can make an invalid API request #3413

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

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

Conversation

Zlendy
Copy link

@Zlendy Zlendy commented May 11, 2025

Details

Error returned: fields: Array must contain at least 1 element(s)

This error is caused because the following zod validation is performed on the server but the client just checks if either fields or filters is defined.

How to reproduce

  1. Create a new Insights report
  2. Define one or more filters but NOT any fields.
  3. Run query
  4. Observe how the button shows an infinite loading spinner and an error is thrown in console

Screenshots

Before After
insights_not_working_filters insights_working_filters

Error returned:
fields: Array must contain at least 1 element(s)
Copy link

vercel bot commented May 11, 2025

@Zlendy is attempting to deploy a commit to the umami-software Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR fixes a validation mismatch in the Insights report where the client allowed reports with only filters while the server required at least one field, causing an infinite loading state.

  • Modified /src/app/(main)/reports/insights/InsightsParameters.tsx to remove filters check from queryEnabled condition, now only requiring websiteId, dateRange, and fields.length
  • Server validation in /src/app/api/reports/insights/route.ts enforces minimum 1 field requirement through zod schema
  • Added clear error handling to prevent infinite loading spinner when validation fails

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant