Unimportant Gmail now avoids filter limits

Welp, after running the script for a while, I hit a limit. Apparently Gmail has a limit on the number of filters you can create. Every time I applied my Unimportant label to a new sender, the script would notice that sender and create a Gmail filter for it. One sender, one filter. It worked well, but once I hit the 1000 filter limit, it stopped being able to create new ones.

I worked with ChatGPT on a fix. I’ve been using it more for coding work lately. We ended up making the filters more dense without changing the overall behavior. Instead of creating one Gmail filter per sender, the script now groups multiple senders into a single Gmail query filter, which is something I used to do manually. Here’s what that looks like:

{from:a@example.com from:b@example.com from:c@example.com}

It still matches exact senders, but it uses a single filter instead of three. Consolidating filters reduced the total count dramatically while keeping the same basic workflow and ChatGPT handled the consolidation over the course of a few hours.

I also tightened up the operational side. The script now understands grouped from: query filters when it checks whether a sender is already covered, so rerunning it should not create duplicate coverage. I had some dupes that were left over from the manual work I was doing before I worked on the script. I also documented the setup a bit more thoroughly so it covers how to run it on a schedule, how to verify it, what files should never be committed, and details rollbacks.

Software still needs to be maintained. Go figure. Small automations are still systems.