Path mapping can break with `--experimental_platform_in_output_dir`
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
With `--experimental_platform_in_output_dir` the outptut dir can be basically any string.
But the logic around path mapping replaces paths with the help of a regex in https://github.com/bazelbuild/bazel/blob/bd518f4162f3f02505ef7fff3e0c2e55a2cb11d2/src/main/java/com/google/devtools/build/lib/analysis/actions/StrippingPathMapper.java#L288-L294
So as soon as you have a platform name that contains anything beyond `[\w_-]` it will escape the mapping in the command line flags (but in the sandbox) and the discrepancy wil most probably break the build.
It happened when migrating from bazel 8.smthg to bazel 9.0.1
cc @fmeum, cf. https://bazelbuild.slack.com/archives/CA31HN1T3/p1775817669172489
### Which category does this issue belong to?
Core
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Use `--experimental_platform_in_output_dir` with platforms that contain dots, and setup path mapping.
Tou also probably need generated artefacts, or at least some `includes = [ ... ]` in your cc_library.
### Which operating system are you running Bazel on?
Ubuntu
### What is the output of `bazel info release`?
9.0.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` ?
```text
```
### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
Not done.
### Have you found anything relevant by searching the web?
See slack link above
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.