Skip to content

Conversation

@eduardo-garcia18
Copy link

@eduardo-garcia18 eduardo-garcia18 commented Sep 4, 2025

Summary by CodeRabbit

  • New Features

    • Added a new "onboarding verification" session type.
    • Session requests now accept an optional resource_id; resource_id is required for onboarding verification and will raise a clear validation error if missing.
  • Tests

    • Expanded session-request coverage, including onboarding verification and related validation scenarios.
  • Chores

    • Version bumped to 2.1.17.

@eduardo-garcia18 eduardo-garcia18 self-assigned this Sep 4, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

Walkthrough

  • Added enum member onboarding_verification ('session.onboarding_verification') to SessionType in cuenca_validations/types/enums.py.
  • Extended SessionRequest in cuenca_validations/types/requests.py with an optional resource_id: Optional[str] = None field and a @model_validator(mode='before') validate_metadata classmethod that requires resource_id when type is SessionType.onboarding_verification.
  • Updated the JSON schema example to include resource_id.
  • Bumped package version in cuenca_validations/version.py from '2.1.16' to '2.1.17'.
  • Added tests in tests/test_requests.py covering SessionRequest behavior (including session.onboarding_verification validation) and retained existing URL validation tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • rogelioLpz
  • felipao-mx

Pre-merge checks (2 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title “Agregar metamap session” uses an ambiguous term not present in the actual changes and fails to highlight that the PR introduces a new onboarding_verification session type and associated resource_id validation. Rename the title to clearly summarize the main change, for example “Add onboarding_verification session type with resource_id validation,” so it directly reflects the new enum member and validation logic.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec22bbf and dacdac9.

📒 Files selected for processing (1)
  • cuenca_validations/version.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cuenca_validations/version.py
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/eduardo-garcia18/AddMetamapSession

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

@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #386   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         1391      1400    +9     
=========================================
+ Hits          1391      1400    +9     
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/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 a9f5359...dacdac9. Read the comment docs.

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

Base automatically changed from new-user-fields to main September 4, 2025 22:14
@eduardo-garcia18 eduardo-garcia18 marked this pull request as ready for review September 10, 2025 00:13
Copy link
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 (3)
cuenca_validations/types/requests.py (2)

550-551: Harden resource_id type (non-empty when provided).

Use NonEmptyStr so empty strings are rejected whenever resource_id is present.

-    resource_id: Optional[str] = None
+    resource_id: Optional[NonEmptyStr] = None

566-571: Align JSON schema example with resource_id usage.

Including resource_id while type is session.registration is confusing. Either switch type to session.metamap_verification or drop resource_id.

-                'type': 'session.registration',
+                'type': 'session.metamap_verification',
...
-                'resource_id': 'some_resource_id',
+                'resource_id': 'some_resource_id',
tests/test_requests.py (1)

61-71: Assert on the actual exception message value.

Use exception.value to avoid relying on ExceptionInfo’s repr.

-    assert 'Resource id expected for this session' in str(exception)
+    assert 'Resource id expected for this session' in str(exception.value)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9f5359 and 82e95f6.

📒 Files selected for processing (4)
  • cuenca_validations/types/enums.py (1 hunks)
  • cuenca_validations/types/requests.py (1 hunks)
  • cuenca_validations/version.py (1 hunks)
  • tests/test_requests.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.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).

**/*.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.

`*...

Files:

  • cuenca_validations/version.py
  • tests/test_requests.py
  • cuenca_validations/types/enums.py
  • cuenca_validations/types/requests.py
🧬 Code graph analysis (2)
tests/test_requests.py (2)
cuenca_validations/types/enums.py (1)
  • SessionType (584-591)
cuenca_validations/types/requests.py (1)
  • SessionRequest (545-573)
cuenca_validations/types/requests.py (1)
cuenca_validations/types/enums.py (1)
  • SessionType (584-591)
🪛 Ruff (0.12.2)
cuenca_validations/types/requests.py

560-560: Avoid specifying long messages outside the exception class

(TRY003)

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

1-1: Version bump looks good.

No issues.

cuenca_validations/types/enums.py (1)

591-591: New session type added correctly.

Enum member name and value are consistent with existing conventions.

tests/test_requests.py (3)

4-8: Imports are appropriate.

Absolute imports from the package are fine in tests.


38-46: Good baseline test.

Covers non-metamap session without extra fields.


48-59: Happy-path test looks good.

Validates mapping and presence of resource_id.

account_entries = 'session.account_entries'
download_file = 'session.download_file'
upload_file = 'session.upload_file'
metamap_verification = 'session.metamap_verification'
Copy link
Member

@rogelioLpz rogelioLpz Sep 10, 2025

Choose a reason for hiding this comment

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

Renombrar a onboarding_verification para que haga mas sentido con el recurso

Copy link
Contributor

Choose a reason for hiding this comment

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

no tiene sentido, porque renombrar a onboarding si no se hace el onboarding con la sesión, simplemente es una sesión para poder consultar una verificación de metamap?

Copy link
Member

Choose a reason for hiding this comment

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

El recurso se llama onboarding_verifications 🤡

Comment on lines 555 to 560
if values[
'type'
] == SessionType.metamap_verification and not values.get(
'resource_id'
):
raise ValueError('Resource id expected for this session')
Copy link
Member

Choose a reason for hiding this comment

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

Por legibilidad sugiero ponerlo así

    def validate_metadata(cls, values: dict) -> dict:
        type, resource_id = values['type'], values.get('resource_id')
        if type == SessionType.onboarding_verification and not resource_id:
            raise ValueError('Resource id expected for this session')

Copy link
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

♻️ Duplicate comments (1)
cuenca_validations/types/requests.py (1)

550-559: Fix enum/str comparison in before-validator; avoid KeyError; don’t shadow built-in type.

In a mode='before' validator, values['type'] is likely a raw str. Comparing it to SessionType.onboarding_verification will silently fail; also direct indexing can raise KeyError. Normalize to SessionType, guard missing/invalid input, and prefer a non-empty type for resource_id. This keeps existing error text (to avoid breaking tests).

Apply:

-    resource_id: Optional[str] = None
+    resource_id: Optional[NonEmptyStr] = None
@@
-    def validate_metadata(cls, values: dict) -> dict:
-        type, resource_id = values['type'], values.get('resource_id')
-        if type == SessionType.onboarding_verification and not resource_id:
-            raise ValueError('Resource id expected for this session')
-        return values
+    def validate_metadata(cls, values: DictStrAny) -> DictStrAny:
+        # In 'before' validators, 'type' is often a raw string; normalize to Enum
+        session_type_raw = values.get('type')
+        if session_type_raw is None:
+            return values  # let field validation handle missing/invalid type
+        try:
+            session_type = (
+                session_type_raw
+                if isinstance(session_type_raw, SessionType)
+                else SessionType(session_type_raw)
+            )
+        except Exception:
+            # Defer invalid enum value errors to field validation
+            return values
+        if (
+            session_type is SessionType.onboarding_verification
+            and not values.get('resource_id')
+        ):
+            raise ValueError('Resource id expected for this session')
+        return values
🧹 Nitpick comments (1)
cuenca_validations/types/requests.py (1)

560-569: Align example with resource_id usage.

The example shows resource_id but type is session.registration. Suggest switching the example type to the flow that requires resource_id for clarity.

-                'type': 'session.registration',
+                'type': 'session.onboarding_verification',
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82e95f6 and ec22bbf.

📒 Files selected for processing (4)
  • cuenca_validations/types/enums.py (1 hunks)
  • cuenca_validations/types/requests.py (1 hunks)
  • cuenca_validations/version.py (1 hunks)
  • tests/test_requests.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • cuenca_validations/types/enums.py
  • tests/test_requests.py
  • cuenca_validations/version.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.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).

**/*.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.

`*...

Files:

  • cuenca_validations/types/requests.py
🧬 Code graph analysis (1)
cuenca_validations/types/requests.py (1)
cuenca_validations/types/enums.py (1)
  • SessionType (584-591)
🪛 Ruff (0.12.2)
cuenca_validations/types/requests.py

557-557: Avoid specifying long messages outside the exception class

(TRY003)

@alexviquez
Copy link
Contributor

@eduardo-garcia18 revisa el stack trace del PR, pareciera que se están incluyendo commits de @gmorales96

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.

5 participants