Skip to content

Changes in KYC Validation#371

Merged
rogelioLpz merged 11 commits intomainfrom
levels
Apr 1, 2025
Merged

Changes in KYC Validation#371
rogelioLpz merged 11 commits intomainfrom
levels

Conversation

@rogelioLpz
Copy link
Copy Markdown
Member

@rogelioLpz rogelioLpz commented Mar 12, 2025

  • Se elimina KYCVerification y se unifica con KYCValidation
  • Se agrega enum KYCValidationMode para indicar si es validación del lado en el cliente o del server.
  • Level maximo permitido es 3

Summary by CodeRabbit

  • New Features

    • Introduced new KYC validation options, offering choices between client-side and server-side processing.
    • Added a new field for specifying the KYC validation source in requests.
  • Bug Fixes

    • Adjusted validation criteria for user requests by lowering the maximum allowed level.
  • Chores

    • Upgraded the software version to 2.1.5 and streamlined available public features by removing outdated entities.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 12, 2025

Walkthrough

The changes introduce a new enumeration class, KYCValidationSource, in the cuenca_validations/types/enums.py file, which includes two members: client and server. In the cuenca_validations/types/requests.py file, the UserRequest class has had its required_level field modified to allow a maximum value of 3 instead of 4, and the minimum value has been changed from -1 to 1. A new field, source_type, of type KYCValidationSource, has been added to the KYCValidationRequest class. The KYCVerificationUpdateRequest class has been removed entirely. The version number in cuenca_validations/version.py has been updated from '2.1.4' to '2.1.5'. Lastly, the __all__ list in cuenca_validations/types/__init__.py has been updated to include KYCValidationSource while removing KYCVerificationUpdateRequest.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (583e6cf) to head (983e102).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #371   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         1296      1297    +1     
=========================================
+ Hits          1296      1297    +1     
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 583e6cf...983e102. Read the comment docs.

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

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

🔭 Outside diff range comments (1)
cuenca_validations/types/requests.py (1)

602-602: ⚠️ Potential issue

Remove excess blank lines

There are too many blank lines here, causing a linting error.

Fix the spacing issue:

 class LimitedWalletRequest(BaseRequest):
     allowed_curp: Curp
     allowed_rfc: Optional[Rfc] = None


-

 class PlatformRequest(BaseModel):
🧰 Tools
🪛 GitHub Actions: test

[error] 602-602: Flake8: E303 too many blank lines (3)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22207bb and eaa4cc2.

📒 Files selected for processing (3)
  • cuenca_validations/types/enums.py (1 hunks)
  • cuenca_validations/types/requests.py (3 hunks)
  • cuenca_validations/version.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.py`: Enforce Relative Imports for Internal Modules

En...

**/*.py: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module directories (for example /src or /library_or_app_name) —and relative imports are not feasible—absolute imports are acceptable. Additionally, if a module is located outside the main module structure (for example, in /tests or /scripts at a similar level), absolute imports are also valid.

Examples and Guidelines:

  1. If a module is in the same folder or a subfolder of the current file, use relative imports. For instance: from .some_module import SomeClass
  2. If the module is located under /src or /library_or_app_name and cannot be imported relatively, absolute imports are allowed (e.g., from library_or_app_name.utilities import helper_method).
  3. If a module is outside the main module directories (for example, in /tests, /scripts, or any similarly placed directory), absolute imports are valid.
  4. External (third-party) libraries should be imported absolutely (e.g., import requests).
  • cuenca_validations/version.py
  • cuenca_validations/types/enums.py
  • cuenca_validations/types/requests.py
`**/*.py`: Rule: Enforce Snake Case in Python Backend
  1. N...

**/*.py:
Rule: Enforce Snake Case in Python Backend

  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic models for API responses):
    • Primary fields must be snake_case.
    • If older clients expect camelCase, create a computed or alias field that references the snake_case field.
    • Mark any camelCase fields as deprecated or transitional.

Examples

Invalid:

class CardConfiguration(BaseModel):
    title: str
    subTitle: str  # ❌ Modified or new field in camelCase

Valid:

class CardConfiguration(BaseModel):
    title: str
    subtitle: str  # ✅ snake_case for new/modified field

    @computed_field
    def subTitle(self) -> str:  # camelCase allowed only for compatibility
        return self.subtitle

Any direct use of camelCase in new or updated code outside of these exceptions should be flagged.

  • cuenca_validations/version.py
  • cuenca_validations/types/enums.py
  • cuenca_validations/types/requests.py
🪛 GitHub Actions: test
cuenca_validations/types/enums.py

[error] 252-252: Flake8: E302 expected 2 blank lines, found 1


[error] 256-256: Flake8: E302 expected 2 blank lines, found 1

cuenca_validations/types/requests.py

[error] 602-602: Flake8: E303 too many blank lines (3)

🔇 Additional comments (4)
cuenca_validations/version.py (1)

1-1: Version updated to development build

The version has been incremented from 2.1.3 to 2.1.4.dev0, correctly indicating a development version with the new KYC validation features.

cuenca_validations/types/requests.py (3)

31-31: Import added for new KYCValidationType enum

The import has been correctly added to the existing import block.


426-426:

Details

❓ Verification inconclusive

User level maximum constraint reduced from 4 to 3

The maximum value for required_level has been reduced from 4 to 3, which affects how high a user can progress in the system.

This might impact existing users who already have a level of 4. Before deploying, please verify that there are no users with level 4 in the production database:


🏁 Script executed:

#!/bin/bash
# Check if there are any users with level 4 that might be affected by this change
echo "You should run a query in your production database to check for:"
echo "SELECT COUNT(*) FROM users WHERE required_level = 4;"
echo "If this count is greater than 0, you'll need a migration plan for these users."

Length of output: 423


Action Required: Verify Production Database for Users with Level 4

The change in cuenca_validations/types/requests.py (line 426) reduces the maximum allowed required_level from 4 to 3. This update may affect existing users if any currently have a level of 4. Before deploying, please verify that there are no such users in the production database by running the following query:

  • SELECT COUNT(*) FROM users WHERE required_level = 4;

If the result is greater than 0, you'll need to prepare a migration plan for these users.


623-623:

Details

✅ Verification successful

Added validation_type field to KYCValidationRequest

The new field correctly uses the KYCValidationType enum and follows the snake_case naming convention.

This change requires that all API consumers now provide a validation_type. Check if there are existing API clients that need to be updated:


🏁 Script executed:

#!/bin/bash
# Search for existing code that calls KYCValidationRequest without validation_type
echo "Searching for existing usage of KYCValidationRequest..."
rg "KYCValidationRequest\(" -A 5 -B 5

Length of output: 805


Action Required: Confirm External API Consumers Update for New Field

I verified that the new validation_type field is correctly added to the KYCValidationRequest declaration, and a repository-wide search did not reveal any invocations of KYCValidationRequest omitting this required parameter. This indicates that internal uses are consistent with the change. However, please ensure that any external API consumers (if any) that instantiate KYCValidationRequest are updated to provide a valid KYCValidationType.

  • File: cuenca_validations/types/requests.py
  • Location: Definition of KYCValidationRequest includes the new field.

Comment thread cuenca_validations/types/enums.py Outdated
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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between aa8dad2 and a498254.

📒 Files selected for processing (2)
  • cuenca_validations/types/requests.py (3 hunks)
  • cuenca_validations/version.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cuenca_validations/version.py
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.py`: Enforce Relative Imports for Internal Modules

En...

**/*.py: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module directories (for example /src or /library_or_app_name) —and relative imports are not feasible—absolute imports are acceptable. Additionally, if a module is located outside the main module structure (for example, in /tests or /scripts at a similar level), absolute imports are also valid.

Examples and Guidelines:

  1. If a module is in the same folder or a subfolder of the current file, use relative imports. For instance: from .some_module import SomeClass
  2. If the module is located under /src or /library_or_app_name and cannot be imported relatively, absolute imports are allowed (e.g., from library_or_app_name.utilities import helper_method).
  3. If a module is outside the main module directories (for example, in /tests, /scripts, or any similarly placed directory), absolute imports are valid.
  4. External (third-party) libraries should be imported absolutely (e.g., import requests).
  • cuenca_validations/types/requests.py
`**/*.py`: Rule: Enforce Snake Case in Python Backend
  1. N...

**/*.py:
Rule: Enforce Snake Case in Python Backend

  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic models for API responses):
    • Primary fields must be snake_case.
    • If older clients expect camelCase, create a computed or alias field that references the snake_case field.
    • Mark any camelCase fields as deprecated or transitional.

Examples

Invalid:

class CardConfiguration(BaseModel):
    title: str
    subTitle: str  # ❌ Modified or new field in camelCase

Valid:

class CardConfiguration(BaseModel):
    title: str
    subtitle: str  # ✅ snake_case for new/modified field

    @computed_field
    def subTitle(self) -> str:  # camelCase allowed only for compatibility
        return self.subtitle

Any direct use of camelCase in new or updated code outside of these exceptions should be flagged.

  • cuenca_validations/types/requests.py
🔇 Additional comments (2)
cuenca_validations/types/requests.py (2)

31-31: Looks good.

The new import statement adheres to the relative import guideline and leverages standard PascalCase for the enum class name. No changes needed.


426-426:

Details

✅ Verification successful

Verify downstream references to updated max level.

Reducing the maximum allowed required_level from 4 to 3 may break or alter existing logic or validations that expect a max of 4. Please confirm there are no other references assuming 4.


🏁 Script executed:

#!/bin/bash
# Search the repository for references to `required_level` to ensure
# no leftover code or tests still assume a maximum of 4 instead of 3.
rg -A 5 'required_level'

Length of output: 751


Downstream references verified for required_level update.
The repository search confirms that all tests and relevant code now use a maximum value of 3 for required_level, with tests in tests/test_types.py explicitly passing required_level=3. There are no references assuming a maximum of 4.

Comment thread cuenca_validations/types/requests.py Outdated
@rogelioLpz
Copy link
Copy Markdown
Member Author

@cuenca-dependabot cierra los comments y vuelve a revisar

@rogelioLpz rogelioLpz changed the title Levels and KYC Changes in KYC Validation Mar 20, 2025
Comment thread cuenca_validations/types/enums.py Outdated
Comment thread cuenca_validations/types/requests.py Outdated
Comment thread cuenca_validations/types/enums.py Outdated
Comment thread cuenca_validations/types/requests.py Outdated
Comment thread cuenca_validations/types/requests.py Outdated
Comment thread cuenca_validations/types/requests.py Outdated
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: 0

🧹 Nitpick comments (1)
cuenca_validations/types/requests.py (1)

622-622:

Details

❓ Verification inconclusive

Consider renaming the validation_flow field for clarity.

The new validation_flow field of type KYCValidationFlow indicates whether validation happens on client or server side, which matches the PR objective. However, previous review comments suggested naming this field validation_source_type or source_type for better clarity.

-    validation_flow: KYCValidationFlow
+    validation_source_type: KYCValidationFlow

Also, remember to add test coverage for this new field, as mentioned in a previous review comment.


🏁 Script executed:

#!/bin/bash
# Check for existing tests of KYCValidationRequest with the validation_flow field
rg -A 5 -B 5 "KYCValidationRequest" tests/

Length of output: 42


Rename Field & Verify Test Coverage

In cuenca_validations/types/requests.py (line 622), please rename the
validation_flow field to validation_source_type so that its purpose—indicating whether
validation is performed on the client or server side—is clearer:

-    validation_flow: KYCValidationFlow
+    validation_source_type: KYCValidationFlow

Additionally, as noted previously, please ensure that proper tests are added to cover
this new field. Since our initial automated search for tests referencing KYCValidationRequest
returned no hits, kindly verify manually that test coverage for this field is in place.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between bcde67d and 315f778.

📒 Files selected for processing (3)
  • cuenca_validations/types/__init__.py (2 hunks)
  • cuenca_validations/types/enums.py (1 hunks)
  • cuenca_validations/types/requests.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • cuenca_validations/types/init.py
  • cuenca_validations/types/enums.py
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.py`: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module dir...

**/*.py: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module directories (for example /src or /library_or_app_name) —and relative imports are not feasible—absolute imports are acceptable. Additionally, if a module is located outside the main module structure (for example, in /tests or /scripts at a similar level), absolute imports are also valid.

Examples and Guidelines:

  1. If a module is in the same folder or a subfolder of the current file, use relative imports. For instance: from .some_module import SomeClass
  2. If the module is located under /src or /library_or_app_name and cannot be imported relatively, absolute imports are allowed (e.g., from library_or_app_name.utilities import helper_method).
  3. If a module is outside the main module directories (for example, in /tests, /scripts, or any similarly placed directory), absolute imports are valid.
  4. External (third-party) libraries should be imported absolutely (e.g., import requests).
  • cuenca_validations/types/requests.py
`**/*.py`: Rule: Enforce Snake Case in Python Backend
  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic...

**/*.py:
Rule: Enforce Snake Case in Python Backend

  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic models for API responses):
    • Primary fields must be snake_case.
    • If older clients expect camelCase, create a computed or alias field that references the snake_case field.
    • Mark any camelCase fields as deprecated or transitional.

Examples

Invalid:

class CardConfiguration(BaseModel):
    title: str
    subTitle: str  # ❌ Modified or new field in camelCase

Valid:

class CardConfiguration(BaseModel):
    title: str
    subtitle: str  # ✅ snake_case for new/modified field

    @computed_field
    def subTitle(self) -> str:  # camelCase allowed only for compatibility
        return self.subtitle

Any direct use of camelCase in new or updated code outside of these exceptions should be flagged.

  • cuenca_validations/types/requests.py
🧬 Code Definitions (1)
cuenca_validations/types/requests.py (1)
cuenca_validations/types/enums.py (1)
  • KYCValidationFlow (253-255)
🔇 Additional comments (3)
cuenca_validations/types/requests.py (3)

31-31: Imported KYCValidationFlow enum correctly.

The addition of KYCValidationFlow to the import list is necessary to support the new validation_flow field in the KYCValidationRequest class. This follows the established pattern for importing enums in this file.


426-429: Adjusted validation range for required_level field.

The validation constraints for required_level have been changed from ge=-1, le=4 to ge=1, le=3, which:

  1. Aligns with the PR objective of setting the maximum allowed level to 3
  2. Removes the ability to set negative or zero values that weren't being used (as noted in past review comments)

This change appears to address the comment from reviewer felipao-mx questioning the purpose of allowing -1 or 0 values.


426-429: Fix redundant Field annotation pattern.

There's a redundancy in using Field both inside the Annotated type and as the default value. This was mentioned in a previous review comment.

Consider simplifying to this pattern for consistency with other fields:

-    required_level: Optional[Annotated[int, Field(ge=1, le=3)]] = Field(
-        None,
-        description='Maximum level a User can reach. ' 'Defined by platform',
-    )
+    required_level: Optional[int] = Field(
+        None, 
+        ge=1, 
+        le=3,
+        description='Maximum level a User can reach. Defined by platform'
+    )

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between b296f23 and a7ae6ee.

📒 Files selected for processing (1)
  • cuenca_validations/types/requests.py (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.py`: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module dir...

**/*.py: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module directories (for example /src or /library_or_app_name) —and relative imports are not feasible—absolute imports are acceptable. Additionally, if a module is located outside the main module structure (for example, in /tests or /scripts at a similar level), absolute imports are also valid.

Examples and Guidelines:

  1. If a module is in the same folder or a subfolder of the current file, use relative imports. For instance: from .some_module import SomeClass
  2. If the module is located under /src or /library_or_app_name and cannot be imported relatively, absolute imports are allowed (e.g., from library_or_app_name.utilities import helper_method).
  3. If a module is outside the main module directories (for example, in /tests, /scripts, or any similarly placed directory), absolute imports are valid.
  4. External (third-party) libraries should be imported absolutely (e.g., import requests).
  • cuenca_validations/types/requests.py
`**/*.py`: Rule: Enforce Snake Case in Python Backend
  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic...

**/*.py:
Rule: Enforce Snake Case in Python Backend

  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic models for API responses):
    • Primary fields must be snake_case.
    • If older clients expect camelCase, create a computed or alias field that references the snake_case field.
    • Mark any camelCase fields as deprecated or transitional.

Examples

Invalid:

class CardConfiguration(BaseModel):
    title: str
    subTitle: str  # ❌ Modified or new field in camelCase

Valid:

class CardConfiguration(BaseModel):
    title: str
    subtitle: str  # ✅ snake_case for new/modified field

    @computed_field
    def subTitle(self) -> str:  # camelCase allowed only for compatibility
        return self.subtitle

Any direct use of camelCase in new or updated code outside of these exceptions should be flagged.

  • cuenca_validations/types/requests.py
🧬 Code Definitions (1)
cuenca_validations/types/requests.py (1)
cuenca_validations/types/enums.py (1)
  • KYCValidationFlow (253-255)
🔇 Additional comments (2)
cuenca_validations/types/requests.py (2)

31-31: LGTM: Import of KYCValidationFlow enum.

The addition of the KYCValidationFlow import is correctly placed and alphabetically ordered within the enums import block.


426-431:

Details

❓ Verification inconclusive

Confirm breaking change in required_level range.

The required_level field's constraints have been modified:

  1. Minimum value changed from -1 to 1
  2. Maximum value reduced from 4 to 3

This is a breaking change that could affect existing code expecting values of -1 or 0 to be valid.


🏁 Script executed:

#!/bin/bash
# Check for existing usage of required_level with values less than 1
# First, search for direct assignments in the codebase
echo "Searching for direct assignments of required_level < 1..."
rg -A 2 -B 2 "required_level\s*=\s*(0|-1)" --type py

# Next, check for any tests that might verify behavior with these values
echo "Searching for tests using required_level < 1..."
rg -A 2 -B 2 "required_level.*(0|-1)" tests/ --type py

Length of output: 341


Breaking Change – Confirm Impact on required_level Constraints

The required_level field now enforces a range of 1–3 (changed from a minimum of -1 and a maximum of 4), which is a breaking change. Automated searches did not reveal any direct assignments or tests using values less than 1. However, since this output isn’t fully conclusive, please manually verify that there are no indirect usages or runtime dependencies expecting the legacy range (e.g., dynamic assignments or validations that might allow -1 or 0).

  • Confirm no indirect assignments or validations are using legacy values.
  • Double-check tests to ensure they do not expect the old range.

Comment thread cuenca_validations/types/requests.py Outdated
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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between a7ae6ee and 983e102.

📒 Files selected for processing (4)
  • cuenca_validations/types/__init__.py (2 hunks)
  • cuenca_validations/types/enums.py (1 hunks)
  • cuenca_validations/types/requests.py (3 hunks)
  • cuenca_validations/version.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • cuenca_validations/version.py
  • cuenca_validations/types/enums.py
  • cuenca_validations/types/init.py
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.py`: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module dir...

**/*.py: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module directories (for example /src or /library_or_app_name) —and relative imports are not feasible—absolute imports are acceptable. Additionally, if a module is located outside the main module structure (for example, in /tests or /scripts at a similar level), absolute imports are also valid.

Examples and Guidelines:

  1. If a module is in the same folder or a subfolder of the current file, use relative imports. For instance: from .some_module import SomeClass
  2. If the module is located under /src or /library_or_app_name and cannot be imported relatively, absolute imports are allowed (e.g., from library_or_app_name.utilities import helper_method).
  3. If a module is outside the main module directories (for example, in /tests, /scripts, or any similarly placed directory), absolute imports are valid.
  4. External (third-party) libraries should be imported absolutely (e.g., import requests).
  • cuenca_validations/types/requests.py
`**/*.py`: Rule: Enforce Snake Case in Python Backend
  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic...

**/*.py:
Rule: Enforce Snake Case in Python Backend

  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic models for API responses):
    • Primary fields must be snake_case.
    • If older clients expect camelCase, create a computed or alias field that references the snake_case field.
    • Mark any camelCase fields as deprecated or transitional.

Examples

Invalid:

class CardConfiguration(BaseModel):
    title: str
    subTitle: str  # ❌ Modified or new field in camelCase

Valid:

class CardConfiguration(BaseModel):
    title: str
    subtitle: str  # ✅ snake_case for new/modified field

    @computed_field
    def subTitle(self) -> str:  # camelCase allowed only for compatibility
        return self.subtitle

Any direct use of camelCase in new or updated code outside of these exceptions should be flagged.

  • cuenca_validations/types/requests.py
🧬 Code Definitions (1)
cuenca_validations/types/requests.py (1)
cuenca_validations/types/enums.py (1)
  • KYCValidationSource (253-255)
🔇 Additional comments (2)
cuenca_validations/types/requests.py (2)

31-31: Relative import of KYCValidationSource is correct.

Using ..types.enums ensures compliance with the guideline to prefer relative imports for internal modules.


426-430:

Details

✅ Verification successful

Range restriction for required_level is consistent with PR objectives.

The new constraints ge=1 and le=3 align with the updated validation rules. However, be sure no legacy logic relies on negative or zero values.

Run this script to confirm no references to negative or zero required_level remain in the codebase:


🏁 Script executed:

#!/bin/bash
rg -A 3 -B 3 "required_level" --type py

Length of output: 819


Validation Range Confirmed for required_level

The new constraints (ge=1 and le=3) in cuenca_validations/types/requests.py (lines 426-430) align with the updated PR objectives. The output of the verification script confirms that all references (e.g., in tests/test_types.py) use valid values (such as 3), with no legacy reliance on negative or zero values.


class KYCValidationRequest(BaseRequest):
user_id: str
source_type: KYCValidationSource
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.

💡 Verification agent

❓ Verification inconclusive

Add coverage for the new source_type field in tests.

The field source_type was added to KYCValidationRequest; ensure it’s validated or tested to confirm correctness.

Execute this script to verify test coverage specifically targeting source_type:


🏁 Script executed:

#!/bin/bash
rg -A 5 "source_type" tests/ --type py

Length of output: 38


Missing Test Coverage for source_type Field
The current grep command revealed no test cases addressing the new source_type field in the KYCValidationRequest type, which means its validation isn’t being explicitly verified in the tests. Please add appropriate tests to confirm that the field functions as intended. For example, include scenarios validating the schema or data that stipulate the proper handling of source_type.

@rogelioLpz rogelioLpz merged commit a27e918 into main Apr 1, 2025
20 checks passed
@rogelioLpz rogelioLpz deleted the levels branch April 1, 2025 19:19
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.

3 participants