Skip to content

fix: encode contact email path identifiers#234

Open
mayankbohradev wants to merge 1 commit into
resend:mainfrom
mayankbohradev:fix/contact-email-path-encoding
Open

fix: encode contact email path identifiers#234
mayankbohradev wants to merge 1 commit into
resend:mainfrom
mayankbohradev:fix/contact-email-path-encoding

Conversation

@mayankbohradev

@mayankbohradev mayankbohradev commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What

  • URL-encodes contact identifiers used in contact URL path segments.
  • Covers Contacts, Contacts.Segments, and Contacts.Topics sync and async paths.
  • Adds regression tests for email identifiers containing URL-reserved characters.

Why

  • Contact APIs accept email identifiers. Emails containing characters like / or ? can change URL path/query parsing when interpolated directly into the path.

Testing

  • .tox/py/bin/pytest --cov=resend --cov-report=xml --doctest-modules tests/contacts_test.py tests/contacts_async_test.py tests/contacts_segments_test.py tests/contacts_segments_async_test.py tests/contact_topics_test.py tests/contact_topics_async_test.py -q
  • .tox/py/bin/pytest --cov=resend --cov-report=xml --doctest-modules tests -q
  • .tox/mypy/bin/mypy --install-types --non-interactive --ignore-missing-imports resend/ examples/ tests/
  • .tox/format/bin/black --check resend/contacts/_contacts.py resend/contacts/segments/_contact_segments.py resend/contacts/_topics.py tests/contacts_test.py tests/contacts_async_test.py tests/contacts_segments_test.py tests/contacts_segments_async_test.py tests/contact_topics_test.py tests/contact_topics_async_test.py
  • .tox/format/bin/isort --check-only resend/contacts/_contacts.py resend/contacts/segments/_contact_segments.py resend/contacts/_topics.py tests/contacts_test.py tests/contacts_async_test.py tests/contacts_segments_test.py tests/contacts_segments_async_test.py tests/contact_topics_test.py tests/contact_topics_async_test.py
  • git diff --check

Note

  • Local lint is blocked because flake8<5 is running under Python 3.12 in this environment and fails before checking source files (EntryPoints has no .get). CI runs lint on Python 3.8-3.11 per the workflow.

Summary by cubic

URL-encodes contact email identifiers in API paths to prevent mis-parsing when emails contain reserved characters. Applies to Contacts, Contacts.Segments, and Contacts.Topics in both sync and async methods.

  • Bug Fixes
    • Encode email identifiers in path segments using urllib.parse.quote(safe="") across update/get/remove, segments add/remove/list, and topics list/update.
    • Add regression tests to verify URL encoding for emails with characters like “/” and “?”.

Written for commit fe234f0. Summary will update on new commits.

Review in cubic

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.79%. Comparing base (7f1acd0) to head (fe234f0).
⚠️ Report is 185 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #234       +/-   ##
===========================================
+ Coverage   82.66%   95.79%   +13.12%     
===========================================
  Files           4       58       +54     
  Lines          75     3137     +3062     
===========================================
+ Hits           62     3005     +2943     
- Misses         13      132      +119     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added the linear-synced PR has been synced to Linear label Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linear-synced PR has been synced to Linear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants