BaseXdb / basex

BaseX Main Repository.
http://basex.org
BSD 3-Clause "New" or "Revised" License
684 stars 265 forks source link

Import module namespace can't follow symlinks in linux anymore #2253

Closed porte-g closed 7 months ago

porte-g commented 11 months ago

Description of the Problem

Hi BaseX team !

I have webapps and some of them have modules/plugins that I used to organize in separate folders (because they are git repo) and that I called inside my webapp with symlinks.

Since BaseX 10 it is not possible anymore.

my folders

webapp ├── ... ├── test -> {path}/test ├── test2 -> {path}/test2 ├── test3 -> {path}/test3

what I get

error

Stopped at {path}/basex/webapp/test2/test3/test3.xq, 3/57:
[XQST0059] Cannot retrieve module: {path}/basex/webapp/test2/test2.xq.

This has major consequences in the workflow of our team and the organization of our git repos. Do you think this could be fixed ?

Expected Behavior

In the description above, it should be possible to import (and use) in test3.xq the module namespace of test2.xq

With BaseX 8 and 9 (not tested before), every module describe above could be called by each of them.

Steps to Reproduce the Behavior

  1. unzip test.zip somewhere
  2. make a symlink inside the /basex/webapp folder that goes to test and test2
    • webapp/test -> {somewhere}/test
    • webapp/test2 -> {somewhere}/test2
  3. make a symlink inside test2 that goes to test3
    • webapp/test2/test3 -> {somewhere}/test3

This should lead to the error


  1. delete webapp/test2/test3

This should work correctly and localhost:XXXX/test2 should display his content

Do you have an idea how to solve the issue?

nope :/

What is your configuration?

Debian 11 Basex 10.7 openjdk 17

ChristianGruen commented 11 months ago

I can’t remember that something fundamental has changed in the way how we resolve module imports, but we’ll try to get this reproduced.

To understand this better: Does the problem only occur when a symlink follows another symlink, or can the example be further simplified?

A side note: When you use the repo directory for the actual application logic, you can omit the module locations. The repo directory location (specified in web.xml or .basex) can also be a symlink.

porte-g commented 11 months ago

Thanks for your answer !

To understand this better: Does the problem only occur when a symlink follows another symlink, or can the example be further simplified?

That's it, the problem occurs (as far as I can tell) when a symlink dir is inside another symlink dir.

choje commented 11 months ago

Hi @ChristianGruen and @porte-g ! It seems to be the same issue I mentioned in that thread : https://mailman.uni-konstanz.de/pipermail/basex-talk/2023-January/017791.html

The test app is still available here. Initial tests were done with BaseX10.4.

ChristianGruen commented 11 months ago

@choje Thanks! Back then, could you resolve the problem by adjusting the permissions?

choje commented 11 months ago

When I said "I changed the repository's permissions" It was about the git repository with restricted access... I really need to improve my english ! The problem is still unresolved but I did not try with last BaseX (10.7).

ChristianGruen commented 11 months ago

When I said "I changed the repository's permissions" It was about the git repository with restricted access... I really need to improve my english ! The problem is still unresolved but I did not try with last BaseX (10.7).

Sorry to hear that, and good to know. I hope I can look into this more closely next week.

ChristianGruen commented 11 months ago

…too busy this week to set up a Linux environment to test this with different versions of BaseX; sorry.

ChristianGruen commented 10 months ago

I spent too much time to try to reproduce the behavior with BaseX 10.0 and 9.7.4 until I noticed it was already introduced with an earlier version (BaseX 9.7.1). It must have been caused by a commit between March 23 and April 26, 2022, possibly by one of…

porte-g commented 10 months ago

Thanks @ChristianGruen for taking the time to take a look on this issue ! I did not understand what you meant though : should I consider it as a feature or a bug ? Or maybe it is an invit to propose a patch ? :D

ChristianGruen commented 10 months ago

;) Sorry, it’s still on the too long to-do list. I can’t even tell exactly if it’s fair to call it a bug, as the way how local URIs are treated has changed in general. Thanks for reminding me; I hope to be able to go on soon.

ChristianGruen commented 9 months ago

A late update (no fix yet): One reason for the 9.7.4 fix was that symbolic links needed to be normalized to ensure that different URIs that point to the same resource can be regarded as equal. A recent proposal for version 4.0 of the languages – https://github.com/qt4cg/qtspecs/issues/898#issuecomment-1855759492 – will allow us to revert the behavior of BaseX and stay compliant at the same time.

porte-g commented 8 months ago

Thanks !

ChristianGruen commented 7 months ago

Thanks @porte-g and @choje for all your patience. A new snapshot is available, which I hope resolves the problem.

porte-g commented 7 months ago

I've just tried with BX110 and the bug did not occur. Thank you !

ChristianGruen commented 7 months ago

I've just tried with BX110 and the bug did not occur. Thank you !

Great news. Thanks for testing!