bazel-contrib / bazel-contrib/bazel-lib
`write_source_files` misclassifies missing or dangling inputs as directories
- Dominant language
- Starlark
- Stars
- 182
- Forks
- 134
- Avg merge
- 1d 46m
- Merged PRs (30d)
- 1
Description
`write_source_files` determines whether an input is a file using this binary check:
```bash
if [[ -f "$in" ]]; then
# copy file
else
# copy directory
fi
```
The else branch assumes that anything not recognized as a regular file must be a directory. However, `[[ -f ]]` also returns false when the input is missing or is a dangling symlink.
This produces a misleading failure. The updater reports that it is copying a directory and may eventually fail with an unrelated error such as:
```text
mkdir: cannot create directory '': File exists
```
The actual problem is that the input is unavailable.
The script should distinguish all three states explicitly:
```bash
if [[ -f "$in" ]]; then
# copy file
elif [[ -d "$in" ]]; then
# copy directory
else
echo "Input is unavailable or is a dangling symlink: $in" >&2
exit 1
fi
```
This would not materialize remotely stored Bazel outputs or otherwise fix their absence. It would provide an accurate, actionable diagnostic instead of treating the missing input as a directory.
Contributor guide
Research direction
Locate the write_source_files entry point and inspect its input-state checks. Verify behavior for a regular file, directory, missing input, and dangling symlink; done means unavailable inputs produce the specified actionable diagnostic on stderr and exit without being treated as directories.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100