-
-
Notifications
You must be signed in to change notification settings - Fork 26.6k
fix: validate top-langs query #2761
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
Conversation
@manhhungpc is attempting to deploy a commit to the github readme stats Team on Vercel.
A member of the Team first needs to authorize it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @manhhungpc.
It will be better to stay a bit loose than this strict req.query checking. Right now even if people add an extraneous query or do a simple mistake this will throw error for the whole card.
Not to mention it might also have a negative side effect - Imagine later down the line we remove or deprecate a query param, now people might not update the URL even if the query param is deprecated but this code will throw error and users will have no idea why it's failing.
Instead it will be better if we don't throw instead if a query param is malformed we just ditch that param's value or default it to something sensible.
Eg for the count_weight if its NaN we just disregard it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @manhhungpc.
It will be better to stay a bit loose than this strict req.query checking. Right now even if people add an extraneous query or do a simple mistake this will throw error for the whole card. Not to mention it might also have a negative side effect - Imagine later down the line we remove or deprecate a query param, now people might not update the URL even if the query param is deprecated but this code will throw error and users will have no idea why it's failing.
Instead it will be better if we don't throw instead if a query param is malformed we just ditch that param's value or default it to something sensible.
Eg for the count_weight if its NaN we just disregard it.
@manhhungpc I agree with @anuraghazra. Let's close this pr for now. Free free to create a new pull request that fixes the NaN bug explained in #2735 by ditching the incorrect parameter value and reverting back to default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manhhungpc on second. To keep a history of the decision above, maybe let's keep this open and apply the changes to this pull request.
Uh oh!
There was an error while loading. Please reload this page.
This commit validate the query to make sure not display NaN percentage and throw an error when have an invalid query. For example:
/api/top-langs?&username=manhhungpc&theme=dark&size_weight=0&count_weight=1langs_count=10&layout=compactwhere&count_weight=1langs_count=10is invalid query. See (#2735) for more details