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

Graceful handling of filter input errors #1228

Open
torgeirl opened this issue May 13, 2022 · 5 comments
Open

Graceful handling of filter input errors #1228

torgeirl opened this issue May 13, 2022 · 5 comments
Assignees
Labels
Milestone

Comments

@torgeirl
Copy link
Collaborator

torgeirl commented May 13, 2022

Multiple filter functions will raise an InvalidFiltersStringError if the input isn't «a valid filter slug». These errors doesn't provide any actionable data, and provide two issues:

  1. in some rare instances we have to take extra steps when handling these errors since they contain user inputs
  2. the errors clutter our error tracking

These issues will potentially grow when we emigrate to another infrastructure, and we should therefore look at addressing the underlying issues in advance.

Some «offenders»:

  • /devilry_admin/assignment/{roleid}/examinerdetails/{relatedexaminer_id}
  • /devilry_admin/assignment/{roleid}/studentoverview/filter/{filters_string}
  • /devilry_admin/period/{roleid}/admins/add/{filters_string}
  • /devilry_admin/period/{roleid}/overview/filter/{filters_string}
  • /devilry_admin/studentfeedbackfeedwizard/user-filter/{filters_string}
  • /devilry_examiner/assignment/{roleid}/bulk-feedback-points-filter/filter/{filters_string}
  • /devilry_examiner/assignment/{roleid}/filter/{filters_string}
  • /devilry_student/allperiods/{filters_string}
  • /devilry_student/period/{roleid}/overview/{filters_string}

All of them seems to be raised from cradmin_legacy/viewhelpers/listfilter/base/filtershandler.py.

Edit: added /devilry_admin/period/{roleid}/overview/filter/{filters_string} to the list on August 14, 2024.

@torgeirl torgeirl added this to the Devilry 5.6 milestone Sep 16, 2022
@torgeirl torgeirl modified the milestones: Devilry 6.0, Devilry 6.1 Jul 12, 2023
@torgeirl torgeirl self-assigned this Aug 24, 2023
@torgeirl torgeirl modified the milestones: Devilry 6.1, Devilry 6.2 Oct 6, 2023
@torgeirl torgeirl removed this from the Devilry 6.2 milestone Nov 3, 2023
@torgeirl torgeirl added this to the Devilry 6.3 milestone Dec 6, 2023
@torgeirl torgeirl removed their assignment Jan 30, 2024
@torgeirl torgeirl self-assigned this Feb 16, 2024
@torgeirl torgeirl modified the milestone: Devilry 6.3 Feb 16, 2024
@torgeirl torgeirl removed their assignment Feb 16, 2024
@torgeirl torgeirl modified the milestones: Devilry 6.3, Devilry 6.4 Feb 16, 2024
@torgeirl torgeirl modified the milestones: Devilry 6.4, Devilry 6.5 Apr 23, 2024
@Levijatan
Copy link
Collaborator

It looks like this error should only be raised when there is an invalid filter in the url. This is also the only way I have been able to trigger it. I think that it would better to ignore invalid filters rather then raising an error. It is not the input that is not «a valid filter slug» it is the name of the filter, so as long as filters are implemented correct there should be no user input in the error though if the url is logged it is right there.

@torgeirl
Copy link
Collaborator Author

torgeirl commented Aug 8, 2024

if the url is logged it is right there

Yes, services like Sentry will store the URL as part of the error.

In the same way that we can implement filter for Sentry's transactions to mask a webhook hash from being passed to Sentry it is probably possible to alter the these URLs from the error messages before they passed on to the Sentry server, but errors gets passed on to other systems as well and it just seems better to handle this issue «at the source».

@torgeirl torgeirl modified the milestones: Devilry 6.5, Devilry 6.4 Aug 9, 2024
@Levijatan
Copy link
Collaborator

Pushed up a fix for this in c09408e. Made a custom FiltersHandler that overrides parse to change it from
if slug not in self.filtermap: raise InvalidFiltersStringError('"{}" is not a valid filter slug.'.format(slug)) self.filtermap[slug].set_values(values)
to
if slug in self.filtermap: self.filtermap[slug].set_values(values)
So it ignores invalid filters instead of raising an error.

@espenak espenak self-assigned this Dec 10, 2024
espenak added a commit that referenced this issue Dec 10, 2024
…d DevilryVertical listfilter list that useses the custom FiltersHandler DevilryFiltersHandler"

This reverts commit c09408e.

Refs: #1228
@espenak
Copy link
Member

espenak commented Dec 10, 2024

This has been fixed in cradmin_legacy instead (in appressoas/cradmin_legacy@64576a2), but update of that is blocked by Django5 (cradmin_legacy and all the dependencies is updated for django5 already), so @torgeirl can we move this to another milestone?

@torgeirl
Copy link
Collaborator Author

@espenak: yeah, let do this alongside #1319 in v6.5!

@torgeirl torgeirl modified the milestones: Devilry 6.4, Devilry 6.5 Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants