Skip to content

Conversation

fm3
Copy link
Member

@fm3 fm3 commented Jun 26, 2025

Relative paths in datasource-properties.json are supposed to be interpreted as relative to the dataset directory. This particular codepath resolved them in the current working directory, which yields wrong results.

Note that this code will probably be changed soon again, when we make those paths (mostly) immutable.

Steps to test:

(I already tested locally)

  • Change datasource with explicit mag paths in allowed way, should work
  • Change a relative mag path to point outside of the organization directory (using ..), should still be rejected

Issues:


  • Added changelog entry (create a $PR_NUMBER.md file in unreleased_changes or use ./tools/create-changelog-entry.py)
  • Needs datastore update after deployment

@fm3 fm3 requested a review from MichaelBuessemeyer June 26, 2025 07:39
@fm3 fm3 self-assigned this Jun 26, 2025
Copy link
Contributor

coderabbitai bot commented Jun 26, 2025

📝 Walkthrough

Walkthrough

This change updates the logic for validating relative paths when editing dataset settings. The path validation in the data source service is now less strict, ensuring paths are checked relative to the organization and data source directories, rather than being overly restrictive.

Changes

Files/Paths Change Summary
webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/DataSourceService.scala Refined path validation logic in validateDataSource to resolve and check paths relative to org and data source directories.
unreleased_changes/8720.md Added changelog entry describing the bug fix for relative path validation during dataset editing.

Possibly related PRs

Suggested reviewers

  • normanrz

Poem

A path once blocked, now clear and bright,
Through folders deep, no longer tight.
The rabbit hops where code was strict,
Now edits flow, no bugs inflict.
With gentle paws, the checks align—
Dataset paths now work just fine! 🐇✨


📜 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 9395ef6 and 489c68c.

📒 Files selected for processing (2)
  • unreleased_changes/8720.md (1 hunks)
  • webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/DataSourceService.scala (1 hunks)
🧰 Additional context used
🪛 LanguageTool
unreleased_changes/8720.md

[duplication] ~1-~1: Possible typo: you repeated a word.
Context: ### Fixed - Fixed a bug where the checks on relative path...

(ENGLISH_WORD_REPEAT_RULE)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-smoketest-push
  • GitHub Check: backend-tests
🔇 Additional comments (2)
webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/DataSourceService.scala (1)

229-232: Path resolution fix looks correct and maintains security boundaries.

The change properly addresses the issue described in the PR objectives by ensuring relative paths are resolved relative to the dataset directory rather than the current working directory. The security validation remains intact - paths are still required to stay within the organization directory boundaries after resolution.

The implementation correctly:

  1. Resolves relative to the organization directory first
  2. Then resolves to the specific dataset directory
  3. Finally resolves the URI path relative to that context
  4. Maintains the security check against the organization directory boundary
unreleased_changes/8720.md (1)

1-2: Changelog entry accurately describes the fix.

The description correctly captures the nature of the bug fix - overly strict path validation when editing dataset settings. The static analysis hint about word repetition appears to be a false positive, as this follows standard changelog format with "Fixed" in both the section header and bullet point.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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 marked this pull request as ready for review June 26, 2025 07:40
Comment on lines +229 to +232
val path = organizationDir
.resolve(dataSource.id.directoryName)
.resolve(Path.of(new URI(pathStr).getPath).normalize())
.toAbsolutePath
Copy link
Contributor

Choose a reason for hiding this comment

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

What about the directory of the layer? Like

val path = organizationDir
          .resolve(dataSource.id.directoryName)
          .resolve(dataLayerName)
          .resolve(Path.of(new URI(pathStr).getPath).normalize())
          .toAbsolutePath

Copy link
Member Author

Choose a reason for hiding this comment

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

We decided recently with @normanrz that the mag paths should be relative to the dataset.

While it is true that some jsons still exist where they are relative to the layer, and wk still allows that, we want to change that soon (possibly migrating said jsons).

I’d say for this particular edge case it is no problem if the check is still too strict

Copy link
Contributor

Choose a reason for hiding this comment

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

Just checked: Absolute and relative Paths. Both worked, but non-existent paths were accepted

Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer left a comment

Choose a reason for hiding this comment

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

Ok thanks for the reply. The fix looks good to me 🎉

Did test with the help of the debugger (relative & absolute path)

@fm3 fm3 merged commit 7c58f29 into master Jun 26, 2025
5 checks passed
@fm3 fm3 deleted the fix-check-for-relative-paths branch June 26, 2025 09:01
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