Skip to content

Conversation

fm3
Copy link
Member

@fm3 fm3 commented Nov 27, 2024

Regression from #8075 – Public datasets could not be accessed without user credentials.

I tested locally that this helps. Looking up the organization bypassing its read access check here is fine, since we already checked that the dataset is public in the line above.

Let’s also test this. #8243

@fm3 fm3 self-assigned this Nov 27, 2024
@fm3 fm3 requested a review from daniel-wer November 27, 2024 19:41
Copy link
Contributor

coderabbitai bot commented Nov 27, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request primarily focus on the DatasetController class within the app/controllers/DatasetController.scala file. The read method has been modified to include a global access context when retrieving the organization for a dataset. Additionally, the segmentAnythingMask method has been enhanced with improved validation and error handling for bounding box parameters, ensuring that they adhere to specified constraints.

Changes

File Change Summary
app/controllers/DatasetController.scala - Updated read method to include GlobalAccessContext in organization retrieval.
- Enhanced validation and error handling in segmentAnythingMask method for bounding box inputs.

Possibly related PRs

Suggested reviewers

  • normanrz
  • MichaelBuessemeyer

Poem

🐇 In the code where datasets play,
A context change brightens the way.
With checks for boxes, neat and tight,
Errors vanish, all feels right!
So hop along, let's code with glee,
For validation sets our data free! 🌟


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

@fm3 fm3 enabled auto-merge (squash) November 27, 2024 19:41
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

🧹 Outside diff range and nitpick comments (1)
app/controllers/DatasetController.scala (1)

Line range hint 479-487: LGTM! Comprehensive validation for segment anything mask parameters.

The validation checks are well-implemented:

  1. Size constraints prevent resource exhaustion
  2. Equal long edges requirement ensures proper image processing
  3. Maximum depth limit of 16 maintains performance

Consider extracting these validation constants into a configuration object for easier maintenance and reuse. For example:

object SegmentAnythingConfig {
  val MaxSize = 1024
  val MaxDepth = 16
  // ... other constants
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6c0a472 and c550a59.

📒 Files selected for processing (1)
  • app/controllers/DatasetController.scala (1 hunks)
🔇 Additional comments (2)
app/controllers/DatasetController.scala (2)

Line range hint 488-495: LGTM! Well-structured validation for interaction parameters.

The validation logic correctly ensures that:

  1. For bounding box interactions: all required coordinates are provided
  2. For point interactions: X and Y coordinates are provided

267-267: LGTM! The fix correctly addresses the public dataset access regression.

Using GlobalAccessContext for organization retrieval is appropriate here since the dataset's public status has already been verified via datasetDAO.findOne(datasetIdValidated)(ctx).

Let's verify that this change doesn't affect private dataset access:

✅ Verification successful

Based on the search results, I can now generate the final response:

Using GlobalAccessContext for organization lookup is consistent with the codebase patterns

The usage of GlobalAccessContext when retrieving organization information is a well-established pattern across the codebase, particularly in scenarios involving public access or basic entity information retrieval. This includes:

  • Dataset-related operations in DatasetService.scala
  • Team information retrieval in Team.scala
  • User profile data in UserService.scala
  • Authentication flows in AuthenticationController.scala

The change aligns with existing practices and correctly implements public dataset access while maintaining security for private resources through the earlier dataset access check.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances where organization access is checked
rg "organizationDAO.findOne.*GlobalAccessContext" -A 5

Length of output: 22790

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

Successfully merging this pull request may close these issues.

2 participants