Patches constructed from 16-bit charset neither error nor apply in single_version_mode
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
I ended up trying to build a patch from a git diff I performed on a windows system. As far as I could tell the patch was having no effect (https://stackoverflow.com/questions/79018238/single-version-override-with-patch-has-no-effect). I eventually dove into adding System.err.printf to bazel's patch code to see what was going on, and it eventually led me to look at my patch not in a text editor but with `od -hc foo.patch`.
Doing so I saw "\xff \xfe '\0' d '\0' i ..." which looks like a 16-bit encoding of the file.
I would have expected an error somewhere for a case like this.
If I have a non-trivial patch and it doesn't actually cause any effects, I would expect to see an error.
I did some `perl -spi -e 's/[\xff\xfe\0]//g' benchmark.patch'` magic and then started seeing the errors I had originally hoped for.
### Which category does this issue belong to?
_No response_
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
[benchmark.patch](https://github.com/user-attachments/files/17229532/benchmark.patch)
I tried to do this in my MODULES.bazel
```
bazel_dep(name = "google_benchmark", version = "1.8.5")
single_version_override(
module_name = "google_benchmark",
patches = ["//:benchmark.patch"],
)
```
### Which operating system are you running Bazel on?
OsX
### What is the output of `bazel info release`?
release 7.3.1
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
_No response_
### What's the output of `git remote get-url origin; git rev-parse HEAD` ?
_No response_
### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
_No response_
### Have you found anything relevant by searching the web?
_No response_
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start with Bazel's patch-handling code and reproduce the issue using the attached benchmark.patch through the MODULES.bazel single_version_override on Bazel 7.3.1. Trace how the 16-bit-encoded patch is read and applied, and verify that an invalid or ineffective patch produces an error rather than silently doing nothing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100