Skip to content

fs: allow backslashes in paths via buckconfig - #1364

Open
daandemeyer wants to merge 1 commit into
facebook:mainfrom
daandemeyer:push-koqlxrtkktnt
Open

fs: allow backslashes in paths via buckconfig#1364
daandemeyer wants to merge 1 commit into
facebook:mainfrom
daandemeyer:push-koqlxrtkktnt

Conversation

@daandemeyer

@daandemeyer daandemeyer commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

File names and relative paths reject backslashes on every platform. On
Windows a backslash is a path separator, but on other platforms it is a
valid path character that occurs in practice. Building OS images, for
example, can produce systemd-escaped names such as
system-systemd\x2dfoo.slice, which Buck2 currently rejects.

Keep rejecting backslashes by default, but add
[buck2] allow_backslashes_in_paths = true to permit them on platforms
where they are not path separators. Treat the setting as daemon startup
configuration so changing it restarts buckd and one daemon cannot mix
path invariants. Windows continues to reject literal backslashes.

Initialize the low-level path policy from the startup configuration in
both the client and daemon. Same-value initialization is idempotent for
--no-buckd, while conflicting values are rejected. This also preserves
the original concrete error type of from_system_path, since validation
no longer performs a fallible environment lookup.

Cover policy initialization, platform behavior, and all affected path
validators in buck2_fs tests. Cover buckconfig parsing in buck2_common,
and document the opt-in in the buckconfig reference.

Signed-off-by: Daan De Meyer daan@amutable.com

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 7, 2026
@daandemeyer daandemeyer changed the title push koqlxrtkktnt fs: allow backslashes in paths via BUCK2_ALLOW_BACKSLASH_IN_PATHS Jul 7, 2026
@meta-codesync

meta-codesync Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D110922815. (Because this pull request was imported automatically, there will not be any future comments.)

@daandemeyer
daandemeyer force-pushed the push-koqlxrtkktnt branch 2 times, most recently from fa09fef to 0c5873d Compare July 18, 2026 20:17
@lf-

lf- commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

I feel vaguely like this should be a buckconfig setting instead; the ergonomics of passing in an env-var are not ideal.

@daandemeyer
daandemeyer force-pushed the push-koqlxrtkktnt branch 3 times, most recently from 36facc0 to 444995a Compare July 21, 2026 19:17
@daandemeyer

Copy link
Copy Markdown
Contributor Author

@lf- Reworked to a buck config option

@daandemeyer daandemeyer changed the title fs: allow backslashes in paths via BUCK2_ALLOW_BACKSLASH_IN_PATHS fs: allow backslashes in paths via buckconfig Jul 21, 2026
@daandemeyer
daandemeyer force-pushed the push-koqlxrtkktnt branch 4 times, most recently from b38d229 to d1388ab Compare July 24, 2026 10:43
File names and relative paths reject backslashes on every platform. On
Windows a backslash is a path separator, but on other platforms it is a
valid path character that occurs in practice. Building OS images, for
example, can produce systemd-escaped names such as
`system-systemd\x2dfoo.slice`, which Buck2 currently rejects.

Keep rejecting backslashes by default, but add
`[buck2] allow_backslashes_in_paths = true` to permit them on platforms
where they are not path separators. Treat the setting as daemon startup
configuration so changing it restarts buckd and one daemon cannot mix
path invariants. Windows continues to reject literal backslashes.

Initialize the low-level path policy from the startup configuration in
both the client and daemon. Same-value initialization is idempotent for
`--no-buckd`, while conflicting values are rejected. This also preserves
the original concrete error type of `from_system_path`, since validation
no longer performs a fallible environment lookup.

Cover policy initialization, platform behavior, and all affected path
validators in buck2_fs tests. Cover buckconfig parsing in buck2_common,
and document the opt-in in the buckconfig reference.

Signed-off-by: Daan De Meyer <daan@amutable.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants