Cache interface does not work with dict semantics
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.6k
- Forks
- 213
- PR merge metrics
- No merged PRs in 30d
Description
When mail_exchanger_lookup() fails to connect to the mail exchanger for a specific domain, it sets the corresponding cache entry to False (line 149). However, lookup_exchanger_in_cache() looks for the string 'False' to figure out if there was an MX connection failure for a domain in cache.
This asymmetry means that caches that implement proper dict semantics (i.e. not coercing all values to strings unlike the Redis driver) fail miserably. I believe that a simple in memory cache like defaultdict(lambda: None) should just work and not fail with TypeError. This behaviour is also the root cause for https://github.com/mailgun/flanker/pull/31.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in flanker/addresslib/validate.py at mail_exchanger_lookup() and lookup_exchanger_in_cache(), then reproduce the failure with an in-memory defaultdict(lambda: None) cache. Compare how failed MX connections are stored and read; done means dict-semantic caches handle the failure without a TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100