`write_source_files` misclassifies missing or dangling inputs as directories

Open Beginner friendly
#1,291 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
bash
Domain
build-system

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.

Description

write_source_files determines whether an input is a file using this binary check:

  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:

  mkdir: cannot create directory '<destination>': File exists

The actual problem is that the input is unavailable.

The script should distinguish all three states explicitly:

  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.

Dominant language
Starlark
Stars
182
Forks
134
Avg merge
2d 15h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazel-contrib/bazel-lib

All issues in bazel-contrib/bazel-lib

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.