Skip to content

test(api): strictly type login code mail tests - #47080

Merged
asukaminato0721 merged 4 commits into
langgenius:mainfrom
ShousenZHANG:codex/strict-login-code-mail-tests
Nov 27, 2026
Merged

asukaminato0721 merged 4 commits into
langgenius:mainfrom
ShousenZHANG:codex/strict-login-code-mail-tests

Conversation

@ShousenZHANG

@ShousenZHANG ShousenZHANG commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Why

Include the login-code mail suite in the existing strict Pyrefly check so CI verifies the types of its fixtures and test functions.

Part of #36288.

Summary

  • Include the login-code mail suite in the existing strict Pyrefly and Ruff checks.
  • Pass the mail service and lazy email-service factory into login-code delivery. The Celery task keeps its registered name, mail queue and three payload arguments.
  • Build a real mail service and renderer around a recording transport in the tests. Check recipients, localized subjects, rendered codes and delivery errors without modifying the shared mail client or deployment branding. Keep the database and Redis fixtures.

Screenshots

Backend changes only.

Verification

  • Compared with main at 76c33f30cd4, the target suite went from 12/34 to 49/49 typed symbols. Across the API, Pyrefly 1.5.0 measured 87.9175% to 87.9408% coverage on the prospective merge (47 more typed symbols, 23 fewer untyped).
  • The registered Celery task passed all 9 local before/after checks. The checks covered localization, malformed payloads, disabled mail and service-construction failure. The login and email unit suites passed, as did the mail provider regression tests.
  • Ruff, import contracts, response contracts, billing client generation, production and strict test type checks, and the repository guards passed locally.
  • The GitHub Actions run passed on ce55e7825e9. The Linux integration artifact recorded all 10 original login-mail cases as passed, including the PostgreSQL and Redis cases.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

From Codex

Copilot AI balanced review requested due to automatic review settings November 24, 2026 09:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions github-actions Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-11-27 06:42:16.059288649 +0000
+++ /tmp/pyrefly_pr.txt	2026-11-27 06:42:04.291226985 +0000
@@ -1502,10 +1502,6 @@
   --> tests/e2e_tests/containers/tasks/test_mail_change_mail_task.py:50:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
   --> tests/e2e_tests/containers/tasks/test_mail_change_mail_task.py:58:20
-ERROR Argument `str | None` is not assignable to parameter `to` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
-   --> tests/e2e_tests/containers/tasks/test_mail_email_code_login_task.py:384:20
-ERROR Argument `str | None` is not assignable to parameter `code` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
-   --> tests/e2e_tests/containers/tasks/test_mail_email_code_login_task.py:385:22
 ERROR Object of class `HumanInputNodeData` has no attribute `delivery_methods` [missing-attribute]
    --> tests/e2e_tests/containers/tasks/test_mail_human_input_delivery_task.py:107:26
 ERROR Argument `Literal['workflow']` is not assignable to parameter `mode` with type `AppMode | SQLCoreOperations[AppMode]` in function `models.model.App.__init__` [bad-argument-type]

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 87.94% 87.96% +0.02%
Strict coverage 87.60% 87.63% +0.02%
Typed symbols 97,500 97,547 +47
Untyped symbols 13,424 13,401 -23
Modules 4675 4675 0

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.46%. Comparing base (e2028aa) to head (51357d1).
⚠️ Report is 135 commits behind head on main.

Files with missing lines Patch % Lines
api/tasks/mail_email_code_login.py 95.45% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #47080      +/-   ##
==========================================
+ Coverage   90.42%   90.46%   +0.04%     
==========================================
  Files        6558     6568      +10     
  Lines      409863   410704     +841     
  Branches    82236    82345     +109     
==========================================
+ Hits       370615   371549     +934     
+ Misses      32864    32760     -104     
- Partials     6384     6395      +11     
Flag Coverage Δ
api 90.23% <97.05%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@asukaminato0721 asukaminato0721 self-assigned this Nov 24, 2026

@asukaminato0721 asukaminato0721 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 inline suggestion at eacf013a50, from a rule learned from earlier reviews in this repository. Reply on the comment if it is wrong.

dify-codereview

@asukaminato0721 asukaminato0721 added the waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address label Nov 24, 2026
@github-actions github-actions Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Nov 26, 2026

@asukaminato0721 asukaminato0721 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 inline suggestion at eea2f15fe7, from a rule learned from earlier reviews in this repository. Reply on the comment if it is wrong.

dify-codereview

@asukaminato0721 asukaminato0721 added waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address and removed waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address labels Nov 27, 2026

@asukaminato0721 asukaminato0721 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 inline suggestion at ce55e7825e, from a rule learned from earlier reviews in this repository. Reply on the comment if it is wrong.

dify-codereview

Comment thread api/extensions/ext_mail.py Resolved
@asukaminato0721 asukaminato0721 added waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address and removed waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address labels Nov 27, 2026

@asukaminato0721 asukaminato0721 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to flag at 51357d13e7.

dify-codereview

@asukaminato0721
asukaminato0721 dismissed stale reviews from themself November 27, 2026 07:15

Nothing left to flag at 51357d1.

@asukaminato0721 asukaminato0721 added waiting-for-reviewer dify-codereview: checked, nothing left for the author; a reviewer's turn and removed waiting-for-author dify-codereview: the author has suggestions, a conflict, failing CI or unresolved threads to address labels Nov 27, 2026
@asukaminato0721
asukaminato0721 added this pull request to the merge queue Nov 27, 2026
Merged via the queue into langgenius:main with commit 3ec320d Nov 27, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files. waiting-for-reviewer dify-codereview: checked, nothing left for the author; a reviewer's turn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants