-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make URI parsing more lenient (#316)
The URI validation logic was too strict in some cases, causing valid lakeFS ref expressions with relative (`~N`, `^N`) or HEAD (`@`) suffixes to be rejected. This commit refactors the relevant regexp to accept these URIs and also makes the relative ref expression parsing more explicit in the regex. Issue: #314
- Loading branch information
Showing
3 changed files
with
84 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from lakefs import Branch, Repository | ||
|
||
from lakefs_spec.spec import LakeFSFileSystem | ||
|
||
|
||
def test_gh_314( | ||
fs: LakeFSFileSystem, | ||
repository: Repository, | ||
temp_branch: Branch, | ||
) -> None: | ||
""" | ||
Regression test for GitHub issue 314: Enable `@` and `~N` syntax | ||
https://github.com/aai-institute/lakefs-spec/issues/314 | ||
""" | ||
|
||
prefix = f"lakefs://{repository.id}/{temp_branch.id}" | ||
datapath = f"{prefix}/data.txt" | ||
|
||
# add new file, and immediately commit. | ||
fs.pipe(datapath, b"data1") | ||
temp_branch.commit(message="Add data.txt") | ||
|
||
fs.pipe(datapath, b"data2") | ||
# Reading the committed version of the file should yield the correct data. | ||
committed_head_path = f"{prefix}@/data.txt" | ||
assert fs.read_text(committed_head_path) == "data1" | ||
|
||
# Reading a relative commit should yield the correct data. | ||
temp_branch.commit(message="Update data.txt") | ||
relative_commit_path = f"{prefix}~1/data.txt" | ||
assert fs.read_text(relative_commit_path) == "data1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters