Skip to content

Configurable filter limit for anonymous users - #1374

Merged
fbacall merged 3 commits into
masterfrom
filter-limit
Aug 28, 2026
Merged

Configurable filter limit for anonymous users#1374
fbacall merged 3 commits into
masterfrom
filter-limit

Conversation

@fbacall

@fbacall fbacall commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary of changes

  • Adds a configurable filter limit that applies to anonymous users, which limits the number of filter values they can apply (does not apply to API requests).
  • Displays a warning message when this limit is hit.
  • Returns a 400 error code and does not filter at all if limit is exceeded.

Motivation and context

Crawlers were hammering production instances by trying every possibly permutation of filters.

Screenshots

image

Checklist

  • I have read and followed the CONTRIBUTING guide.
  • I confirm that I have the authority necessary to make this contribution on behalf of its copyright owner and agree to license it to the TeSS codebase under the BSD license.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a configurable “filter value” limit for anonymous HTML requests to reduce crawler-driven load, with UI feedback when the limit is reached and a 400 error when it’s exceeded (while exempting API/JSON:API requests).

Changes:

  • Enforces an anonymous-user facet/value limit in the shared searchable index concern and renders a 400 error when exceeded (HTML only).
  • Updates search UI helpers/views/styles to show a warning and disable further filter application when the limit is reached.
  • Adds i18n messaging, example configuration, and controller tests covering anonymous vs logged-in vs API behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/controllers/materials_controller_test.rb Adds coverage for warning + 400 behavior across anonymous/logged-in/API requests.
config/tess.example.yml Documents the new filter_limit setting in the example config.
config/locales/en.yml Adds the translated warning/error message for filter-limit enforcement.
app/views/search/common/_search_panel.html.erb Displays an informational alert when the filter limit is reached.
app/views/search/common/_facet_sidebar_boolean_filter.html.erb Disables boolean facet checkbox interaction when the limit is reached.
app/helpers/search_helper.rb Prevents generating filter links when the limit is reached; adds filter_limit_reached?.
app/controllers/concerns/searchable_index.rb Introduces a before_action to reject over-limit anonymous HTML requests.
app/assets/stylesheets/base/_facets.scss Styles .nav-item > span to match existing facet link styling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/helpers/search_helper.rb
Comment thread app/helpers/search_helper.rb
Comment thread app/controllers/concerns/searchable_index.rb
Comment thread app/controllers/concerns/searchable_index.rb
Comment thread config/tess.example.yml Outdated
@fbacall
fbacall merged commit e426920 into master Aug 28, 2026
11 checks passed
@fbacall
fbacall deleted the filter-limit branch August 28, 2026 18:33
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.

2 participants