mirror of
https://github.com/mattermost/mattermost.git
synced 2026-08-29 02:28:16 +08:00
6941f56901
* [MM-70252] Reject malformed date filters in logs query API The POST /api/v4/logs/query endpoint parsed date_from/date_to with a fixed layout and swallowed parse errors, silently dropping the bound instead of signalling the caller. A malformed date_from became the zero time and a malformed date_to became now, so the request returned HTTP 200 with an unfiltered result set. Add LogFilter.IsValid, which rejects a non-empty bound that cannot be parsed with the shared LogFilterDateLayout while keeping empty strings meaning "unbounded", and call it from queryLogs so a bad filter returns 400 naming the offending field and the expected layout. Co-authored-by: mattermost-code <matty-code@mattermost.com> * [MM-70252] Add tests for logs query date filter validation Add a unit test for LogFilter.IsValid covering empty (unbounded), valid, and malformed bounds, and an api4 integration test that drives POST /logs/query through the real router to assert malformed date_from/date_to return 400 with the offending field id while empty and valid bounds return 200. Co-authored-by: mattermost-code <matty-code@mattermost.com> * [MM-70252] Harden logs query date filter tests Address test-quality review: exercise the DateTo validation branch with a valid non-empty DateFrom, move fallible checks out of the require.Eventually condition to avoid a cross-goroutine failure, and make each api4 subtest self-contained by polling for the expected messages via a shared helper so valid-bounds also verifies filtering still returns records. Co-authored-by: mattermost-code <matty-code@mattermost.com> * [MM-70252] Retrigger CI/CodeRabbit after invalid public-module feedback Co-authored-by: mattermost-code <matty-code@mattermost.com> * [MM-70252] Note shared LogFilterDateLayout usage in date filter Co-authored-by: mattermost-code <matty-code@mattermost.com> * [MM-70252] Add Client4.QueryLogs to simplify logs query date filter tests * Address PR feedback: 2 answered, 1 resolved, 0 declined --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: mattermost-code <matty-code@mattermost.com> Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>