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 — Agent-mode `apply` can't apply Maven patch records keyed by jar member paths, although `vendor` accepts the same record · Issue #264 · SocketDev/socket-patch

Agent-mode apply can't apply Maven patch records keyed by jar member paths, although vendor accepts the same record #264

New issue
Copy link
New issue
Copy link
Closed
Closed
Agent-mode apply can't apply Maven patch records keyed by jar member paths, although vendor accepts the same record#264
Copy link
Labels
agent:triagedbugSomething isn't workingSomething isn't workingpm:mavenMavenMavenpriority:p3

Description

@mikolalysenko
Mikola Lysenko (mikolalysenko)
opened on Sep 26, 2026
Issue body actions

[agent] Filed by Claude Code on behalf of Mikola Lysenko (@mikolalysenko) while adding Maven patch SBOM annotations to depscan. Repro artifacts were produced with real Maven and a stub patch API.

Summary

Maven patch records are keyed differently depending on the consumer:

  • Vendored mode (vendor, scan/get --mode vendored) treats record file keys as jar member paths (META-INF/NOTICE.txt, org/…/Foo.class). It extracts the cached jar, applies the patch to the members, and re-zips.
  • Agent mode (apply) resolves the keys relative to the version directory (~/.m2/repository/<g>/<a>/<v>/<key>) and never opens the jar.

So one API record cannot serve both modes. The Socket patch backend builds Maven patches as jar-member overlays: depscan's maven repacker applies the record's files as jar entries at the archive root. Every such patch therefore fails in agent mode.

Impact

Agent mode (scan --sync, get + apply) is unusable for real Socket Maven patches. It fails with apply_failed: … File not found, and the jar in ~/.m2 stays unpatched. The docker e2e only passes because its record uses a version-directory key (package/commons-lang3-3.12.0.pom).

Repro

Stage one record in .socket/manifest.json with a blob, keyed META-INF/NOTICE.txt (git-sha256 before/after of the member, exactly like e2e_vendor_maven_build::stage_manifest). MAVEN_REPO_LOCAL holds Central's commons-lang3 3.12.0 jar and pom.

socket-patch apply --json --offline
  -> exit 1 {"status":"partialFailure","events":[{"action":"failed","errorCode":"apply_failed",
             "error":"Cannot apply patch: META-INF/NOTICE.txt - File not found"}]}
  ~/.m2 jar: PRISTINE
socket-patch vendor --json --offline   (same manifest)
  -> exit 0 {"events":[{"action":"applied","files":[{"path":"META-INF/NOTICE.txt","verified":true,"appliedVia":"blob"}]}]}

Expected vs actual

  • Expected: agent-mode apply handles Maven records whose keys are not version-directory files by patching the jar's members in place. It could reuse the vendored stage_local_jar / member-apply path, rewriting the jar and its .sha1, and keeping the rollback before-blob as the original jar. Alternatively it refuses Maven member-keyed records up front with a clear code that recommends --mode hosted/vendored.
  • Actual: a generic "File not found" failure.

CLI revision

3efdc31d

Suggested fix

  • Share the vendored jar-member application with apply, keyed off "the record key is not a file in the version directory, but is an entry in <a>-<v>[-<classifier>].jar".
  • Add a docker/e2e case with a member-keyed record.
  • Rollback and VEX (vex_consumed maven copies) need to agree on the after-hash semantics: member hash vs. whole-jar hash.

File refs (at 3efdc31)

  • crates/socket-patch-core/src/patch/apply.rs (no jar/zip handling; see the classifier comment near l.350)
  • crates/socket-patch-core/src/vendor/maven_repo.rs:153-420 (vendor_maven: member-level apply + deterministic re-zip)
  • crates/socket-patch-cli/tests/docker_e2e_maven.rs:109-116 (version-dir keys only)

Activity

  1. Mikola Lysenko (mikolalysenko)
    added
    bugSomething isn't workingSomething isn't working
    priority:p3
    agent:triaged
    pm:mavenMavenMaven
    on Sep 30, 2026
  2. Mikola Lysenko (mikolalysenko)
    added a commit that references this issue on Oct 5, 2026

    Full Gradle support in agent, hosted and vendored modes (#646)

    0685ba8
  3. mikolalysenko commented on Oct 6, 2026

    @mikolalysenko
    Mikola Lysenko (mikolalysenko)
    on Oct 6, 2026
    CollaboratorAuthor
    More actions

    [agent] Janitor: closing as completed. PR #646 (merge 0685ba8c, "Full Gradle support in agent, hosted and vendored modes") added socket-patch-core/src/patch/jvm_jar.rs ("Agent-mode patches of JVM jars (#264)"). apply_maven_base (commands/apply.rs:2480) handles every pkg:maven record: jvm_jar::classify detects a member-keyed record, and apply_jar_swap replaces each consumed ~/.m2 and Gradle copy with the patch service's jar after verifying the member hashes. The original is kept in .socket/jvm-originals/ for byte-exact rollback. Offline, the record refuses with jvm_agent_service_required and writes nothing. Tests: member_record_apply_repair_rollback_is_byte_exact (tests/gradle_agent_cli.rs:1153) and gradle_agent_264_member_record_whole_jar (tests/e2e_gradle_agent_build.rs). CLI_CONTRACT.md documents it under "Agent mode". These tests use a Gradle-shaped fixture. If a pom.xml-only project still fails, reopen this with the repro.


    Generated by Claude Code

  4. Mikola Lysenko (mikolalysenko)
    closed this as completedon Oct 6, 2026
  5. Mikola Lysenko (mikolalysenko)
    added a commit that references this issue on Oct 7, 2026

    sbt, Mill and scala-cli support in agent, hosted and vendored modes (#…

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:triagedbugSomething isn't workingSomething isn't workingpm:mavenMavenMavenpriority:p3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.