Advanced search date field accepts years with more than four digits without validation

AI-generated summary

olivia reports a bug where the Advanced Search date field accepts years with more than four digits, leading to unsupported search queries. The issue occurs when users manually edit the year portion of the date input; for example, entering a six-digit year like 202666 results in a query such as before:202666-11-12 being submitted without any validation error or warning. The expected behavior is for the field to restrict input to four digits or provide a validation message. The root cause is identified as the native HTML date input lacking a max restriction, while the backend expects a standard four-digit year. A fix for this issue is currently under review, as linked by the reporter.

:information_source: Overview

The date field in Advanced Search allows users to enter years with more than four digits, which results in an unsupported search query.

:walking_woman: Steps to reproduce

  1. Search for discourse on Meta using Chrome.

  2. Expand Advanced filters.

  3. Under Posted, select before.

  4. Enter November 12, 2026.

  5. Replace the year 2026 with 202666 and press Tab.

  6. Click Search.

:white_check_mark: Expected results

The year should be limited to four digits, or a validation message should be displayed.

:x: Observed results

The date field accepts the six-digit year and submits discourse before:202666-11-12 without any validation message.

:books: Additional context

The native date input has no max restriction, while the search backend expects a four-digit year.

A fix is already in review: FIX: Cap the year in native date inputs at four digits - Pull Request #47255 - discourse/discourse - GitHub