Skip to content

Email fetch handler ignores shared keyword filters, mis-maps 72_hours timeframe, and can't OR subjects/senders #3609

Open

Description

@chubes4

Problem

The email fetch handler exposes the shared fetch settings (search, exclude_keywords, timeframe_limit) from FetchHandlerSettings::get_common_fields(), but it ignores or misreads them. A flow configured through the UI or CLI looks filtered but isn't.

Found while designing a Festival Wire flow (wire.extrachill.com, pipeline 1) that should pick up festival lineup press releases from an inbox.

1. Include/exclude keywords are ignored

Email::executeFetch() never calls applyKeywordSearch() / applyExcludeKeywords(). RSS, WordPress API, WordPress posts and media all do (FetchRssAbility.php:282, etc.). So search: "lineup, festival" and exclude_keywords: "film, WordCamp" have no effect on email flows.

2. 72_hours timeframe silently becomes "all time"

datamachine_timeframe_limit offers all_time, 24_hours, 72_hours, 7_days, 30_days. Email::timeframeToDate() keeps its own map (24_hours, 7_days, 30_days, 90_days, 6_months, 1_year) that has no 72_hours. That returns null, so no SINCE gets appended. 72_hours is the value every Reddit flow on the wire uses, so it's the obvious choice for an email flow too.

3. No way to match more than one subject or sender

subject_filter and from_filter each take a single value appended to the IMAP search. Raw OR in search_criteria isn't an option either: PHP's c-client imap_search() rejects it (Unknown search criterion: OR (errflg=2), verified on prod). Combined with #1, the only way to catch "lineup" OR "festival" OR "fest" is one flow per term.

Even after #1 is fixed, keyword filtering runs after the max_messages cap (default 10, newest first). On an inbox getting ~54 messages a day, a broad ALL SINCE fetch would drop matches before the keyword filter ever sees them.

Target state

  • Email items go through the same include/exclude keyword filtering as the other fetch handlers (subject + body text), applied before the max_messages cap so matches aren't starved.
  • timeframe_limit uses the shared datamachine_timeframe_limit filter (or a map that covers every option it offers). An unknown value should not silently fall back to all-time.
  • Multi-value subject_filter / from_filter (comma-separated, OR'd), done by running one IMAP search per value and merging and deduping the UIDs.
  • Tests cover each case.

Activity

  1. chubes4 commented on Oct 13, 2026

    @chubes4
    MemberAuthor

    Fixed in #3611. This was finalized outside Homeboy with operator authorization, because the review test gate runs zero tests (Extra-Chill/homeboy#15333). Cook runs agent-task-b13bd486-ff78-42ec-aeb8-eeea26822500 and agent-task-ec9dba4a-0ee4-43e6-bb70-0020c45e9614 failed on that gate, not on the code. The runtime was OpenCode in session ses_eca61bdf7ffe2C1WCSzkdhQb64, and the verification evidence is in the PR body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions