Skip to content

add fraud funds helpers#403

Open
rcabrera-py wants to merge 7 commits into
mainfrom
feat/add-transfer-fraud-models
Open

add fraud funds helpers#403
rcabrera-py wants to merge 7 commits into
mainfrom
feat/add-transfer-fraud-models

Conversation

@rcabrera-py
Copy link
Copy Markdown
Contributor

@rcabrera-py rcabrera-py commented May 15, 2026

Summary by CodeRabbit

  • New Features

    • Added fraud funds transfer request, queued acceptance response, and result event types
    • Result events validate differently for succeeded vs failed outcomes
  • Tests

    • Added tests covering new models, normalization of transfer fields, and succeeded/failed event validation
  • Chores

    • Version bumped to 2.1.32.dev2

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds three Pydantic models for fraud funds transfer flows: FraudFundsTransferRequest (with CLABE validation and concepto normalization), FraudFundsTransferAcceptedResponse (status fixed to "queued"), and FraudFundsTransferResultEvent (event_type-dependent required fields enforced by a validator). Exposes the types via package exports, adds unit tests for normalization and conditional event payload validation, and bumps package version to 2.1.32.dev2.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • felipao-mx
  • rogelioLpz
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'add fraud funds helpers' is vague and does not clearly summarize the main changes, which involve adding three specific Pydantic models (FraudFundsTransferRequest, FraudFundsTransferAcceptedResponse, and FraudFundsTransferResultEvent) with validation logic, tests, and a version bump. Consider using a more descriptive title such as 'Add fraud funds transfer models and validation' or 'Add FraudFundsTransfer request/response/event models' to better reflect the specific changes introduced.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-transfer-fraud-models

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (bb508a6) to head (85f5438).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #403   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         1474      1493   +19     
=========================================
+ Hits          1474      1493   +19     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

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

Files with missing lines Coverage Δ
cuenca_validations/types/__init__.py 100.00% <ø> (ø)
cuenca_validations/types/enums.py 100.00% <100.00%> (ø)
cuenca_validations/types/requests.py 100.00% <100.00%> (ø)
cuenca_validations/version.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb508a6...85f5438. Read the comment docs.

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

@rcabrera-py rcabrera-py force-pushed the feat/add-transfer-fraud-models branch from 41ff8e2 to e4e497e Compare May 15, 2026 18:36
@rcabrera-py rcabrera-py changed the title Update version to 2.1.31.dev0 and add FraudFundsTransferRequest, Frau… Update version to 2.1.32 and add FraudFundsTransferRequest, Frau… May 15, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cuenca_validations/types/requests.py`:
- Around line 321-326: Remove redundant custom CLABE validator: the
validate_clabe_format field validator duplicates validation provided by the
Clabe type. Delete the `@field_validator-decorated` method validate_clabe_format
and its body from the class, keep the Clabe type import and the field annotated
as clabe: Clabe so Pydantic handles format validation, and ensure no other code
references validate_clabe_format remains.

In `@cuenca_validations/version.py`:
- Line 1: The package version constant __version__ is set to '2.1.32.dev0' but
the PR objective specifies '2.1.31.dev0'; update the __version__ value in
version.py to match the PR objective (set __version__ to '2.1.31.dev0') or
alternatively update the PR description to '2.1.32.dev0' so both the code and PR
intent are consistent, ensuring the published artifact version matches the PR.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e53107db-e349-46f3-acba-81b35adf1c37

📥 Commits

Reviewing files that changed from the base of the PR and between 9708d0b and e4e497e.

📒 Files selected for processing (4)
  • cuenca_validations/types/__init__.py
  • cuenca_validations/types/requests.py
  • cuenca_validations/version.py
  • tests/test_types.py

Comment thread cuenca_validations/types/requests.py Outdated
Comment thread cuenca_validations/version.py Outdated
@rcabrera-py rcabrera-py force-pushed the feat/add-transfer-fraud-models branch from d1fedb9 to 668e01a Compare May 15, 2026 19:18
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cuenca_validations/types/requests.py`:
- Around line 316-319: Several fields (e.g., amount, reason, request_id,
requested_by) use PEP 604 union syntax like `StrictPositiveInt | None` which
breaks on Python 3.9; replace each `X | None` with `Optional[X]` and add `from
typing import Optional` if missing, updating all nine occurrences across the
module (look for other attributes using `| None` and similar patterns) so
annotations match the project's Python 3.9 compatibility and existing style.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7752b25b-cce1-4d6c-a1ec-f27ed8a64930

📥 Commits

Reviewing files that changed from the base of the PR and between d1fedb9 and 668e01a.

📒 Files selected for processing (2)
  • cuenca_validations/types/requests.py
  • cuenca_validations/version.py
✅ Files skipped from review due to trivial changes (1)
  • cuenca_validations/version.py

Comment thread cuenca_validations/types/requests.py Outdated
@rcabrera-py rcabrera-py force-pushed the feat/add-transfer-fraud-models branch from 668e01a to b457ec9 Compare May 15, 2026 19:29
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/test_types.py (1)

642-652: ⚡ Quick win

Strengthen concepto normalization coverage with mixed-case input.

Current assertion proves whitespace trimming, but it would still pass if lowercasing normalization regresses. Add at least one mixed-case sample to lock normalization behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_types.py` around lines 642 - 652, The test currently checks
whitespace trimming for the FraudFundsTransferRequest.concepto but doesn't
assert normalization of case; update test_fraud_funds_transfer_models to include
at least one mixed-case input (e.g., '  FoNdOs FraUdE  ') when constructing
FraudFundsTransferRequest and assert that request.concepto == 'fondos fraude'
(or add a second instance with that mixed-case input and assert normalized
lowercased value) to lock the expected lowercasing behavior of the concepto
normalization.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cuenca_validations/types/requests.py`:
- Around line 342-365: Remove the custom `@model_validator` validate_payload on
FraudFundsTransferResultEvent and instead define two variant models (e.g.,
FraudFundsTransferSucceeded and FraudFundsTransferFailed) that set event_type =
Literal['fraud_funds_transfer.succeeded'] or
Literal['fraud_funds_transfer.failed'] and declare transaction_id and amount
(for succeeded) and reason_code and message (for failed) as required
(non-Optional) fields; then change the payload type to a
Union[FraudFundsTransferSucceeded, FraudFundsTransferFailed] and use Field(...,
discriminator="event_type") so Pydantic enforces event-specific required fields
automatically.

---

Nitpick comments:
In `@tests/test_types.py`:
- Around line 642-652: The test currently checks whitespace trimming for the
FraudFundsTransferRequest.concepto but doesn't assert normalization of case;
update test_fraud_funds_transfer_models to include at least one mixed-case input
(e.g., '  FoNdOs FraUdE  ') when constructing FraudFundsTransferRequest and
assert that request.concepto == 'fondos fraude' (or add a second instance with
that mixed-case input and assert normalized lowercased value) to lock the
expected lowercasing behavior of the concepto normalization.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1706b203-ddad-408e-adc6-04a58c63aa53

📥 Commits

Reviewing files that changed from the base of the PR and between b457ec9 and 63b5848.

📒 Files selected for processing (3)
  • cuenca_validations/types/requests.py
  • cuenca_validations/version.py
  • tests/test_types.py
✅ Files skipped from review due to trivial changes (1)
  • cuenca_validations/version.py

Comment thread cuenca_validations/types/requests.py Outdated
@rcabrera-py rcabrera-py force-pushed the feat/add-transfer-fraud-models branch from af8c2c7 to 4edc524 Compare May 15, 2026 21:55
@rcabrera-py rcabrera-py force-pushed the feat/add-transfer-fraud-models branch from 69cc1ef to 15736df Compare May 25, 2026 18:24
@rcabrera-py rcabrera-py changed the title Update version to 2.1.32 and add FraudFundsTransferRequest, Frau… Update version to 2.1.33 and add FraudFundsTransferRequest, Frau… May 25, 2026
@rcabrera-py rcabrera-py changed the title Update version to 2.1.33 and add FraudFundsTransferRequest, Frau… add FraudFundsTransferRequest, Frau……dFundsTransferAcceptedResponse, and FraudFundsTransferResultEvent models with validation logic and tests. Jun 3, 2026
@rcabrera-py rcabrera-py changed the title add FraudFundsTransferRequest, Frau……dFundsTransferAcceptedResponse, and FraudFundsTransferResultEvent models with validation logic and tests. add fraud funds helpers Jun 3, 2026
…dFundsTransferAcceptedResponse, and FraudFundsTransferResultEvent models with validation logic and tests.
…models to use union types for optional fields and update the validate_payload method to return Self.
…and FraudFundsTransferResultEvent models to use Optional for fields, removing validation logic for CLABE format.
…ired fields, and update related tests accordingly.
… response classes, while removing deprecated ones. Update related tests accordingly.
@rcabrera-py rcabrera-py force-pushed the feat/add-transfer-fraud-models branch from 47a0740 to 85f5438 Compare June 3, 2026 17:23
Comment on lines +82 to +87
class FraudFundsTransferReasonCode(str, Enum):
user_not_found = 'USER_NOT_FOUND'
user_not_fraud_blocked = 'USER_NOT_FRAUD_BLOCKED'
insufficient_funds = 'INSUFFICIENT_FUNDS'
clabe_invalid = 'CLABE_INVALID'
internal_error = 'INTERNAL_ERROR'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Borrar esta enum

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants