Skip to content

[repo-assist] Add regression test confirming square brackets are escaped in nupkg entries (#3906) - #4420

Open
github-actions[bot] wants to merge 4 commits into
masterfrom
repo-assist/fix-issue-3906-bracket-escape-test-dee11b6b93f7a4a9
Open

github-actions[bot] wants to merge 4 commits into
masterfrom
repo-assist/fix-issue-3906-bracket-escape-test-dee11b6b93f7a4a9

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This is an automated contribution from Repo Assist, an automated AI assistant.

Relates to #3906 ("paket pack doesn't escape square brackets").

Investigation

I traced the packing pipeline in NupkgWriter.fs (ensureValidName, used by addEntryFromFile) and tested it directly against a file named file[0].txt. In the current codebase, this path already produces a correctly escaped zip entry name (file%5B0%5D.txt), not the unescaped file[0].txt reported in the issue. I could not find any git history since the issue was filed indicating a targeted fix, so this may have been resolved indirectly (e.g. via the Uri-based round-trip in ensureValidName), or the original repro used a different, older Paket version.

Since I can't rule out a repro path I haven't hit, I'm not claiming the issue is fully resolved — but I've added a regression test to lock in and document the current (correct) behavior, so any regression here would be caught immediately.

Change

  • New test tests/Paket.Tests/Packaging/NupkgWriterSpecs.fs: packs a folder containing file[0].txt via NupkgWriter.Write and asserts the resulting nupkg's zip entry is lib/net461/file%5B0%5D.txt (escaped), not the raw bracketed name.
  • Registered the new file in Paket.Tests.fsproj.

No production code changes — this is a pure test addition intended to give maintainers confidence and a safety net while they decide on the final disposition of #3906.

Test Status

  • dotnet test tests/Paket.Tests/Paket.Tests.fsproj --filter "FullyQualifiedName~NupkgWriter": Passed on net10.0 (1/1).
  • The net461 target aborted in this sandbox only because mono is not installed here (infrastructure limitation, unrelated to the change) — worth re-running in CI where mono is available.

I'll also leave a comment on #3906 summarizing this finding so maintainers can confirm whether the issue is fully closed or if there's another repro path to track down.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@ae8d551f07c7ed7619f8c58c7bb4c3ac89395d38

…nupkg entries

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme
dsyme marked this pull request as ready for review September 1, 2026 15:48
@dsyme

dsyme commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

/repo-assist fix the failing CI

@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor Author

✗ Repo Assist encountered failed, see workflow run.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

The regression test added in this PR for #3906 failed in CI on the
net461/Mono legs (Linux and Windows), even though it passed on net10.0.

Root cause: ensureValidName in NupkgWriter.fs percent-encodes the target
path with Uri.EscapeDataString, then round-trips it through
Uri.GetComponents(SafeUnescaped) / Uri.GetComponents(UriEscaped) to
restore characters that are valid in file/folder names but were escaped
unnecessarily (e.g. '@'). That round-trip treats square brackets
('[' / ']') as "safe" on some runtimes (unescaping them back to literal
brackets) but not on others, producing inconsistent, runtime-dependent
zip entry names.

Fix: percent-encode '[' and ']' the same way the existing '@'/'+'/'%'
"problem characters" are protected - hide them from the Uri round-trip
with a placeholder, then substitute their fixed percent-encoded form
back in afterwards. This makes escaping deterministic across runtimes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor Author

🤖 This is an automated response from Repo Assist.

Fixed the failing CI. The regression test I added for #3906 was itself exposing a real cross-runtime inconsistency in NupkgWriter.ensureValidName:

  • The percent-encoded target path is round-tripped through Uri.GetComponents(SafeUnescaped) / Uri.GetComponents(UriEscaped) to restore characters that are valid in file names but were escaped unnecessarily (e.g. @).
  • That round-trip treats [/] as "safe" on some runtimes (unescaping them back to literal brackets) but not on others (net10.0 kept them escaped, Mono/net461 on Linux and Windows CI legs did not) — producing runtime-dependent zip entry names and failing the new test on those legs.

Fix: [ and ] are now protected the same way the existing @/+/% "problem characters" are — hidden from the Uri round-trip with a placeholder and substituted back to their fixed %5B/%5D form afterwards, in src/Paket.Core/Packaging/NupkgWriter.fs.

Test Status

  • dotnet test tests/Paket.Tests/Paket.Tests.fsproj --filter "FullyQualifiedName~NupkgWriter" (net10.0): Passed (1/1).
  • Ran on net10.0 only in this sandbox (no Mono available here), so the net461/Mono legs should be re-verified in CI — they are the legs that were actually failing.
  • Verified the surrounding UtilsSpecs/PackageProcessSpecs failures seen in a broader local run are pre-existing sandbox artifacts unrelated to this change (reproduced identically with git stash).

Added a RELEASE_NOTES.md bullet since this changes packaging output for filenames containing brackets.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@4bc8419fad05e6b032741cbfd189986700bcf71c

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant