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

impl user max collections #1800

Merged
merged 1 commit into from
Jan 10, 2025
Merged

Conversation

emrgnt-cmplxty
Copy link
Contributor

@emrgnt-cmplxty emrgnt-cmplxty commented Jan 10, 2025

Important

Reduce user max collections limit from 10 to 5 and enforce this limit in create_collection in collections_router.py.

  • Behavior:
    • In collections_router.py, create_collection now checks if a user has reached their max collections limit (5) and raises R2RException if exceeded.
  • Configuration:
    • Change default_max_collections_per_user from 10 to 5 in base.py and r2r.toml.

This description was created by Ellipsis for 7f14361. It will automatically update as commits are pushed.

@emrgnt-cmplxty emrgnt-cmplxty marked this pull request as ready for review January 10, 2025 17:56
@emrgnt-cmplxty emrgnt-cmplxty merged commit 5950cc1 into main Jan 10, 2025
2 of 3 checks passed
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 7f14361 in 1 minute and 41 seconds

More details
  • Looked at 52 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. py/core/main/api/v3/collections_router.py:180
  • Draft comment:
    The condition should be > instead of >= to prevent creating a collection when the limit is reached.
            if (user_collections_count + 1) > user_max_collections:
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    Let's think about what each operator means here:
  • With >= : If max is 5, stops at 5 collections (4+1 >= 5)
  • With > : If max is 5, stops at 6 collections (5+1 > 5)
    The >= seems correct since we want to enforce the max limit exactly, not allow one more.
    Could there be a reason to allow users to have exactly max_collections rather than max_collections-1? Maybe the product requirement is unclear.
    No, the current code with >= is more intuitive - if max_collections is 5, users should be able to have 5 collections total, not 6. The error message also supports this interpretation by saying "maximum number of collections allowed".
    The comment should be deleted. The current >= operator correctly enforces the maximum collection limit, while changing to > would incorrectly allow one extra collection beyond the limit.

Workflow ID: wflow_qLDGl8ApXCtVTH4v


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

auth_user.id
)
)
if (user_collections_count + 1) >= user_max_collections:
Copy link
Contributor

Choose a reason for hiding this comment

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

This validation logic is duplicated. Consider extracting this into a shared utility function to maintain consistency in collection limit checks.

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.

1 participant