Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency/update cuenca validations #413

Merged
merged 7 commits into from
Jan 28, 2025

Conversation

gmorales96
Copy link
Contributor

@gmorales96 gmorales96 commented Jan 27, 2025

Description

This PR updates the project to use the latest version of cuenca-validations

Changes

  • Replacing HttpUrl and AnyUrl with SerializableHttpUrl and SerializableAnyUrl, respectively, to avoid serialization issues.
  • Adapting to the updated password field in cuenca-validations, which is now of type SecretStr with a minimum of 8 characters.
  • Adding logic in user_credentials.py to handle serialization of password when it is a SecretStr by using its get_secret_value() method.

Summary by CodeRabbit

Release Notes v2.0.1

  • New Features

    • Enhanced URL handling with improved serialization capabilities
  • Bug Fixes

    • Updated password handling for improved security
  • Chores

    • Updated cuenca-validations package to version 2.0.4
    • Bumped library version to 2.0.1
  • Internal Improvements

    • Refined type management for URLs across multiple resources
    • Improved credential management methods

Copy link

coderabbitai bot commented Jan 27, 2025

Walkthrough

This pull request introduces several modifications across multiple files in the Cuenca project. The primary changes involve updating URL-related type annotations from standard Pydantic types like HttpUrl and AnyUrl to custom serializable types such as SerializableHttpUrl and SerializableAnyUrl. These changes are primarily located in resource files like endpoints.py, files.py, sessions.py, and users.py. Additionally, the pull request updates the package version to 2.0.1, modifies the cuenca-validations dependency to version 2.0.4, and includes minor adjustments to test files related to user credentials. The modifications suggest an effort to improve URL handling and serialization within the project.

Possibly related PRs

  • update cuenca-validations #406: The changes in this PR involve updating the cuenca-validations package, which is relevant because the main PR modifies URL types to SerializableHttpUrl, likely requiring the updated validation capabilities from this package.
  • Update version to 2.0.0 in version.py for stable release #412: While this PR focuses on updating the version number, it is related in the context of ensuring that the overall project version aligns with the changes made in the main PR, particularly if those changes depend on the updated validation library.

Suggested reviewers

  • alexviquez
  • rogelioLpz
  • felipao-mx
  • pachCode

📜 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 14c4f2f and 4b82c7d.

📒 Files selected for processing (1)
  • cuenca/resources/user_credentials.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • cuenca/resources/user_credentials.py

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@gmorales96 gmorales96 marked this pull request as ready for review January 27, 2025 22:10
Copy link

codecov bot commented Jan 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (1be86d8) to head (4b82c7d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #413   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           49        49           
  Lines         1087      1095    +8     
=========================================
+ Hits          1087      1095    +8     
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/resources/endpoints.py 100.00% <100.00%> (ø)
cuenca/resources/files.py 100.00% <100.00%> (ø)
cuenca/resources/sessions.py 100.00% <100.00%> (ø)
cuenca/resources/user_credentials.py 100.00% <100.00%> (ø)
cuenca/resources/users.py 100.00% <100.00%> (ø)
cuenca/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 1be86d8...4b82c7d. Read the comment docs.

Copy link

@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 (4)
tests/resources/test_user_credentials.py (1)

10-12: Add test cases for password validation.

While the password length updates align with the new minimum length requirement, consider adding test cases for:

  • Passwords shorter than 8 characters (should fail)
  • Edge cases around the 8-character limit
  • Password validation error scenarios
cuenca/resources/user_credentials.py (2)

29-32: Consider updating type hints for password parameter.

Since the password field in UserCredentialRequest is now SecretStr, consider updating the type hint of the password parameter from str to str | SecretStr to make it more explicit.


47-50: Verify SecretStr handling in update method.

The implementation correctly handles password serialization, but consider:

  1. Updating the password parameter type hint to Optional[str | SecretStr]
  2. Adding a comment explaining why we need to handle SecretStr specifically
setup.py (1)

27-27: Consider adding an upper bound to the version constraint.

While >=2.0.4 allows using the new serializable URL types, it's recommended to specify an upper bound (e.g., >=2.0.4,<3.0.0) to prevent potential breaking changes from future major versions.

-        'cuenca-validations>=2.0.4',
+        'cuenca-validations>=2.0.4,<3.0.0',
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1be86d8 and 14c4f2f.

📒 Files selected for processing (10)
  • cuenca/resources/endpoints.py (4 hunks)
  • cuenca/resources/files.py (2 hunks)
  • cuenca/resources/sessions.py (2 hunks)
  • cuenca/resources/user_credentials.py (3 hunks)
  • cuenca/resources/users.py (2 hunks)
  • cuenca/version.py (1 hunks)
  • requirements.txt (1 hunks)
  • setup.py (1 hunks)
  • tests/resources/cassettes/test_update_password.yaml (3 hunks)
  • tests/resources/test_user_credentials.py (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • requirements.txt
  • cuenca/version.py
🔇 Additional comments (8)
cuenca/resources/user_credentials.py (1)

8-8: LGTM! Import of SecretStr from pydantic.

The import aligns with the PR objective of adapting to the updated password field type.

tests/resources/cassettes/test_update_password.yaml (1)

3-3: LGTM! Consistent password length updates in test fixtures.

The password length updates in the test fixtures align with the new minimum length requirement and maintain consistency with the test file changes.

Also applies to: 57-57, 111-111

cuenca/resources/sessions.py (1)

20-21: LGTM! Type updates are consistent with PR objectives.

The change from Optional[AnyUrl] to Optional[SerializableAnyUrl] aligns with the goal of improving URL serialization.

cuenca/resources/files.py (1)

17-17: LGTM! Type update is consistent with PR objectives.

The change from HttpUrl to SerializableHttpUrl aligns with the goal of improving URL serialization.

cuenca/resources/endpoints.py (1)

18-18: LGTM! Type updates are comprehensive and consistent.

The changes from HttpUrl to SerializableHttpUrl are consistently applied across:

  • Class field definition
  • create method parameter
  • update method parameter

This aligns with the goal of improving URL serialization.

Also applies to: 55-55, 76-76

cuenca/resources/users.py (3)

18-18: LGTM! Import changes align with the migration to serializable URL types.

The addition of SerializableHttpUrl from cuenca_validations.types.general is consistent with the PR's objective to update URL-related type annotations.


Line range hint 155-169: Verify UserUpdateRequest compatibility with SerializableHttpUrl.

The usage of curp_document in the request model looks good. Let's verify that UserUpdateRequest in cuenca-validations is updated to handle SerializableHttpUrl.


151-151: Verify consistent usage of SerializableHttpUrl for CURP documents.

The type update for curp_document looks good. Let's verify that this change is consistently applied across the codebase.

✅ Verification successful

Type change for curp_document is consistently applied

The codebase shows consistent usage of Optional[SerializableHttpUrl] for the curp_document parameter, with no remaining instances of the old type.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining HttpUrl usage for CURP documents
rg -l "HttpUrl.*curp_document|curp_document.*HttpUrl"

# Search for SerializableHttpUrl usage with CURP documents to ensure consistency
rg -l "SerializableHttpUrl.*curp_document|curp_document.*SerializableHttpUrl"

Length of output: 187


Script:

#!/bin/bash
# Show all occurrences of HttpUrl and SerializableHttpUrl with CURP documents with context
rg "HttpUrl.*curp_document|curp_document.*HttpUrl|SerializableHttpUrl.*curp_document|curp_document.*SerializableHttpUrl" -C 3

Length of output: 592

@gmorales96 gmorales96 requested a review from felipao-mx January 28, 2025 00:19
@pachCode pachCode merged commit f338ff4 into main Jan 28, 2025
18 checks passed
@pachCode pachCode deleted the dependency/update-cuenca-validations branch January 28, 2025 01:48
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