Fix warning when using an absolute path which exists inside the project
Currently, as it stands, if we specify an absolute pathway to something within our project, BuildStream will fail, see below:
$ pwd
/home/jennis/project
$ ls
elements project.conf some_file.txt
$ cat elements/import_file.bst
kind: import
sources:
- kind: local
path: /home/jennis/project/some_file.txt
$ bst build import_file.bst
[--:--:--][][] START Build
[--:--:--][][] START Loading elements
[00:00:00][][] SUCCESS Loading elements
[--:--:--][][] START Resolving elements
[00:00:00][][] FAILURE Resolving elements
[00:00:00][][] FAILURE Build
import_file.bst [line 4 column 8]: Specified path '/home/jennis/project/some_file.txt' must not lead outside of the project directory
The error message is incorrect as this path does not lead outside of the project
This patch ensures that we receive an appropriate error message.
Merge request reports
Activity
- Resolved by James Ennis
-
The error message is incorrect, this path does not lead outside of the project
-
BuildStream should not fail if this is the case
I agree that the error message is incorrect in this case. However, I'm not sure whether we actually want to allow this (my gut feeling says we don't). Can you please provide some context on why you want/need this?
-
added 1 commit
- b5f79674 - tests/source: Add tests for invalid absolute paths
475 475 is_inside = project_dir_path.resolve() in full_resolved_path.parents or ( 476 476 full_resolved_path == project_dir_path) 477 477 478 if path.is_absolute() or not is_inside: 478 if not is_inside: 479 479 raise LoadError(LoadErrorReason.PROJ_PATH_INVALID, 480 480 "{}: Specified path '{}' must not lead outside of the " 481 481 "project directory" 482 482 .format(provenance, path_str)) 483 483 484 if path.is_absolute() and is_inside: 485 raise LoadError(LoadErrorReason.PROJ_PATH_INVALID, @jennis you actually did not address my comment here. Previously, all the error messages started with "Specified path"… With your MR, this consistency is lost.
- Resolved by James Ennis
added 35 commits
-
1af9609e...8071c00c - 34 commits from branch
master
- 1d7053ed - _yaml.py: Fix incorrect error message
-
1af9609e...8071c00c - 34 commits from branch
enabled an automatic merge when the pipeline for 1d7053ed succeeds
added 3 commits
-
1d7053ed...c6306b88 - 2 commits from branch
master
- 9fa8a881 - _yaml.py: Fix incorrect error message
-
1d7053ed...c6306b88 - 2 commits from branch
enabled an automatic merge when the pipeline for 9fa8a881 succeeds
mentioned in commit fb8860db