GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix quoted and ${VAR} requirements includes (#994) by mikolalysenko · Pull Request #995 · SocketDev/socket-patch

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Fixes #994

Summary

Lock-only discovery now follows a -r / --requirement include the way pip does. Covered forms: a quoted path (-r "dev reqs.txt", -r 'dev reqs.txt', -r "dev.txt"), a backslash-escaped path (-r dev\ reqs.txt), a quoted long form (--requirement "dev.txt", --requirement="dev.txt"), an attached quoted short form (-r"dev reqs.txt"), and an env-var path (-r ${REQDIR}/dev.txt). Before this change, scan exited 0 with "No patches available" (lockfileOnlyPackages: 0) while pip installed the include's unpatched pins. The vendored planner, the in-use / prune probe, repair and lock-only vex use the same grammar, so they now see these includes too.

Root cause

include_target (crates/socket-patch-core/src/vendor/pypi_requirements.rs) is the single include grammar behind lock-only discovery (lock_inventory::pypi::requirements_tree), the vendored planner (requirements_includes) and the in-use / prune / repair / lock-only VEX probe (requirements_include_names). It splits an include line on whitespace and keeps the target as written. pip parses the same line differently:

  1. it expands ${NAME} ([A-Z0-9_]+) from the environment, then
  2. it shlex.splits the option part (POSIX quoting and backslash escapes).

So pip follows -r "dev reqs.txt", -r 'dev reqs.txt', -r "dev.txt", -r dev\ reqs.txt, -r ${REQDIR}/dev.txt, --requirement "dev.txt" and --requirement="dev.txt", while socket-patch resolves each one to a file that doesn't exist and skips it silently.

Fix

include_target now reads an include line the way pip's req_file.py does:

  1. strip the comment;
  2. expand ${NAME} ([A-Z0-9_]+, from the environment; an unset or empty variable stays as written);
  3. shlex.split the line in POSIX mode;
  4. read the -r X / -rX / --requirement X / --requirement=X forms.

Two helpers, expand_env_vars and shlex_split, live in utils::requirements with the rest of the shared pip grammar. Their unit tests are checked against Python's shlex.split.

The absolute-include refusal test (pin_in_absolute_include_refuses) now writes its Windows temp path quoted, since pip needs it quoted on Windows. The unquoted form failed test (windows-latest) on 65112a8.

Behaviour change worth noting: -r sub\dev.txt (an unquoted Windows-style separator) now resolves to subdev.txt, which is what pip reads on every OS, since shlex drops the backslash. Before, it resolved to sub/dev.txt, which pip itself doesn't open. --requirement= dev.txt (a space after =) still reads dev.txt, as before.

The commit 65112a8 is #878's fix for the main-red production_digests_go_through_the_helpers guard, ported unchanged. It becomes a no-op once #878 lands.

Test evidence

Issue Regression test Without fix With fix
#994 quoted / escaped forms (dq, sq, dq_nospace, bs, longq, eqq, attached), hosted and --vendor scan_requirements_lock_only::lock_only_scan_discovers_quoted_include_targets FAIL: lockfileOnlyPackages: 0 pass
#994 -r ${REQDIR}/dev.txt, hosted and --vendor scan_requirements_lock_only::lock_only_scan_discovers_env_var_include_target FAIL: lockfileOnlyPackages: 0 pass
#994 grammar matrix vendor::pypi_requirements::tests::include_target_unquotes_and_expands_like_pip n/a (new fn) pass
#994 vendored planner and include names vendor::pypi_requirements::tests::quoted_include_with_space_is_followed n/a pass
helpers utils::requirements::tests::{shlex_split_matches_python_posix_mode, expand_env_vars_follows_pips_name_grammar} n/a pass

Local checks:

  • cargo clippy --workspace --all-features -- -D warnings: clean.
  • cargo test --workspace --all-features: 226 suites green.
    • The sandbox runs as root, so 12 tests that need a write to fail on a read-only directory fail there, on main as well. All 12 pass when re-run as a non-root user.
  • cargo fmt on the touched files is clean. CI has no fmt job, and main already has rustfmt drift in other files, which I left alone.
  • No wrapper (npm/, pypi/, gem/) changes are needed: they only dispatch to the binary.

Follow-up, not in this PR: the issue also suggests warning when an include can't be resolved, instead of skipping it silently. This PR fixes the misreading itself, so pip-valid includes are followed. A warning for genuinely broken includes would be a separate change.

🤖 Generated with Claude Code


Generated by Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@claude
Start fix for #994
c419e43
Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko Mikola Lysenko (mikolalysenko) mentioned this pull request Oct 7, 2026
Lock-only requirements.txt discovery skips -r includes that are quoted, backslash-escaped or use ${VAR} (-r "dev reqs.txt", --requirement="dev.txt", -r ${DIR}/dev.txt), so the scan exits 0 with "No patches" while pip installs the include's unpatched pins #994
Closed
Claude (claude) added 2 commits October 7, 2026 08:49
@claude
Follow quoted and ${VAR} requirements includes
59b8cb2
pip expands ${NAME} references and shlex-splits the options of a
requirements line, so it follows `-r "dev reqs.txt"`, `-r dev\ reqs.txt`,
`--requirement="dev.txt"` and `-r ${REQDIR}/dev.txt`. socket-patch kept
the quotes, backslashes and ${...} in the include target, resolved it to
a file that doesn't exist and skipped it silently. Lock-only scans then
reported "No patches" (exit 0) while pip installed the include's
unpatched pins, and the vendored planner, in-use probe, repair and
lock-only VEX were blind to the same includes.

include_target now reads the line the way pip's req_file.py does:
comment stripped, ${NAME} expanded from the environment, then a POSIX
shlex split, then the -r / --requirement option forms. The new
expand_env_vars and shlex_split helpers live with the shared
requirements grammar.

Fixes #994

Assisted-by: Claude Code:claude-opus-5-5
@claude
Route Gradle digests through utils::digest
65112a8
main has failed socket-patch-core's lib tests since Gradle support
(#646) and the digest helpers (#865) both landed. The guard test
production_digests_go_through_the_helpers flags three files #646 added
that still hash inline: crawlers/gradle_cache.rs, patch/jvm_jar.rs and
patch/sidecars/maven.rs. That breaks test, test-release and coverage on
every open PR.

Each inline sha1/sha256 call now goes through sha1_hex_of or
sha256_hex_of, which compute the same lowercase hex. Behaviour is
unchanged.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

[agent] CI on the start commit c419e43 (empty, so the same code as main) failed in two places. Neither failure comes from this PR:

  • coverage: utils::digest::tests::production_digests_go_through_the_helpers fails on main too (9c43dfc scheduled run: coverage, test (macos/windows), test-release). Open PR Route Gradle digests through utils::digest #878 fixes it. I ported its commit here as 65112a8, unchanged. It becomes a no-op once Route Gradle digests through utils::digest #878 lands.
  • e2e (macos-latest, e2e_vendor_bun_build, 1.4.2): every failing test panicked with failed to run socket-patch binary: Os { code: 88, "Malformed Mach-o file" } before any test body ran. That points to a corrupt binary artifact on the runner, not a test failure. The same job passes on main. It reruns on the new head 65112a8.

Generated by Claude Code

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 7, 2026 09:16
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

cursor[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Oct 7, 2026
View reviewed changes

@cursor cursor Bot left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@claude
Quote the absolute include in the Windows test
b081c1a
pip shlex-splits a requirements line on every OS, so an unquoted
Windows path like -r C:\dir\shared.txt loses its backslashes and pip
can't open it. The absolute-include refusal test wrote that unquoted
form and failed on Windows once includes were read the way pip reads
them. Write the path quoted, the form pip needs on Windows. The
refusal it checks is unchanged.

Refs #994

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

cursor[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Oct 7, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b081c1a. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

[agent] Ready for review at b081c1a.

  • CI: all 538 check runs are green or skipped on b081c1a. The main-red digest guard passes here because Route Gradle digests through utils::digest #878's fix is ported in.
  • Bugbot: reviewed b081c1a, no findings, no open threads.
  • Regression tests: both Lock-only requirements.txt discovery skips -r includes that are quoted, backslash-escaped or use ${VAR} (-r "dev reqs.txt", --requirement="dev.txt", -r ${DIR}/dev.txt), so the scan exits 0 with "No patches" while pip installs the include's unpatched pins #994 end-to-end tests failed before the fix (lockfileOnlyPackages: 0) and pass after it, in hosted and --vendor mode.

Generated by Claude Code

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 7, 2026
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

[agent] Burn-down: labeled Ready for review at b081c1a.

  • CI: 538/538 check runs green or skipped on b081c1a (532 success, 6 skipped). The branch is 0 commits behind main.
  • Bugbot: reviewed b081c1a, check passed, no open threads.
  • Reviewer note: 65112a8 is Route Gradle digests through utils::digest #878's digest-guard fix ported unchanged, so it becomes a no-op once Route Gradle digests through utils::digest #878 lands. One behaviour change is intentional: an unquoted -r sub\dev.txt now resolves the way pip does (subdev.txt).

Slack announcement is still pending: this run's Slack connector has no send tool, so the slack-announced marker is left off for a later run to retry.


Generated by Claude Code

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Tanmay182003
Tanmay Singla (Tanmay182003) approved these changes Oct 7, 2026
View reviewed changes
@mikolalysenko
Mikola Lysenko (mikolalysenko) merged commit db83f01 into main Oct 7, 2026
539 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/fix-requirements-include-shlex branch October 7, 2026 12:40
This was referenced Oct 7, 2026
Fix uv dry run missing inline [tool.uv] refusal (#979) #980
Merged
Lock-only requirements.txt discovery skips a -r include that follows another option on the same line (--pre -r dev.txt, -i <url> -r dev.txt), so the scan exits 0 with "No patches" while pip installs the include #1028
Closed
@mikolalysenko Mikola Lysenko (mikolalysenko) mentioned this pull request Oct 30, 2026
Vendored pip: a six==${SIXV} pin in requirements.txt (pip expands ${VAR} on every line) doesn't contest a pylock.toml wiring, so vendor --check passes and vex attests not_affected while pip install -r installs the unpatched release #1873
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cursor cursor[bot] cursor[bot] left review comments
@Tanmay182003 Tanmay Singla (Tanmay182003) Tanmay182003 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Lock-only requirements.txt discovery skips -r includes that are quoted, backslash-escaped or use ${VAR} (-r "dev reqs.txt", --requirement="dev.txt", -r ${DIR}/dev.txt), so the scan exits 0 with "No patches" while pip installs the include's unpatched pins

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mikolalysenko @Tanmay182003 @claude
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.