Skip to content

vendor --dry-run and repair --dry-run under --offline say they would redownload a missing vendored artifact and exit 0; the run they preview exits 1 #2385

Backlog

Description

[agent] Filed by the architecture refactor routine. Not claimed: three of its PRs are open, so this run opens none.

Problem

An offline run cannot fetch a vendored artifact from the patch service, and says so. Four previews (--dry-run) reach that refusal, and two of them never ask it. When a vendored package's committed artifact is missing, or no longer matches the ledger, under --offline or SOCKET_OFFLINE=1:

Command --dry-run The run it previews
vendor exit 0, "status": "success", a verified event with wouldRedownload: true, Would vendor 1 package; 1 already vendored. exit 1, partialFailure, vendor_redownload_failed: --vendor-source=service needs the network but --offline is set
repair exit 0, "status": "success", wouldRedownload: true, Would redownload 1 vendored artifact exit 1, partialFailure, vendor_artifact_redownload_failed, the same sentence

The other two previews of the same refusal agree with their runs:

Command, offline --dry-run The run
vendor over a package that is not vendored yet exit 1, failed, vendor_service_offline_conflict the same
repair with a missing agent-mode blob exit 1, 1 blob is missing (offline mode - not downloading) the same

Who it hurts. A pipeline with no route to the patch service that previews before it acts. repair --dry-run --offline (or vendor --dry-run --offline) passes and names a download the run cannot make, and the step after it fails. The state needs no hand edit: a fresh clone lacks a vendored artifact whenever a .gitignore rule matches it (#2348).

What settles the right answer. CLI_CONTRACT.md says --offline "means the same thing on every command (v3.0): never contact the network, fail loudly when a required local source is missing", and says of the hosted undo that "--dry-run runs the same checks, so it previews the failure". The two previews that agree are the copies most callers go through. Core's test of the backends names the rule "Dry-run parity" (offline_service_mode_in_sync_dry_run_is_not_refused, core vendor/golang.rs, line 2316).

Evidence on main (cfc870f)

The npm project of tests/vendor_ecosystem_fixtures (two packages), vendored, then alpha's tarball deleted:

$ socket-patch repair --dry-run --offline        # exit 0
All blobs are present locally.

Would redownload 1 vendored artifact:
  - pkg:npm/alpha@1.0.0 (missing: .socket/vendor/npm/11111111-1111-4111-8111-000000000001/alpha-1.0.0.tgz)

Checked 2 blobs: all in use.

Dry run: no changes made.

$ socket-patch repair --offline                  # exit 1
All blobs are present locally.

Redownloading 1 broken vendored artifact...

Checked 2 blobs: all in use.
Error: Cannot repair vendored artifact for pkg:npm/alpha@1.0.0: vendor_service_offline_conflict: --vendor-source=service needs the network but --offline is set

Repair finished with errors.

$ socket-patch vendor --dry-run --offline        # exit 0
Would vendor 1 package; 1 already vendored.

$ socket-patch vendor --offline                  # exit 1
Vendored 0 packages; 1 already vendored; 1 failed.
Error: Cannot vendor pkg:npm/alpha@1.0.0: vendor_service_offline_conflict: --vendor-source=service needs the network but --offline is set

vendor --dry-run --offline --json says "status": "success" with {"action": "verified", "purl": "pkg:npm/alpha@1.0.0", "details": {"wouldRedownload": true, …}}; vendor --offline --json says "status": "partialFailure" with {"action": "failed", "errorCode": "vendor_redownload_failed", …}.

The control, the same project after vendor --revert, so that nothing is vendored yet:

$ socket-patch vendor --dry-run --offline        # exit 1
Would vendor 0 packages; 2 failed.
Error: Cannot vendor pkg:npm/alpha@1.0.0: --vendor-source=service needs the network but --offline is set
Error: Cannot vendor pkg:npm/beta@1.0.0: --vendor-source=service needs the network but --offline is set

A test over all ten vendored fixtures. It compares the exit code and the envelope's status of each preview with its run, and fails on main in every one:

#[path = "common/mod.rs"]
mod common;
#[path = "vendor_ecosystem_fixtures/mod.rs"]
mod fx;

fn exit_and_status(out: (i32, String, String)) -> (i32, String) {
    let doc: serde_json::Value = serde_json::from_str(&out.1).expect("one JSON document");
    (out.0, doc["status"].as_str().unwrap_or("?").to_string())
}

#[test]
fn offline_dry_run_previews_the_offline_run_over_a_missing_artifact() {
    let offline = [("SOCKET_OFFLINE", "1")];
    let mut disagree = Vec::new();
    for eco in fx::ALL {
        let f = fx::Fixture::new(eco);
        let (code, _, err) = f.vendor(&[], &[]);
        assert_eq!(code, 0, "{eco}: {err}");
        let state: serde_json::Value =
            serde_json::from_slice(&std::fs::read(f.root.join(".socket/vendor/state.json")).unwrap())
                .unwrap();
        let entry = state["entries"].as_object().unwrap().values().next().unwrap();
        let artifact = f.root.join(entry["artifact"]["path"].as_str().unwrap());
        if artifact.is_dir() {
            std::fs::remove_dir_all(&artifact).unwrap();
        } else {
            std::fs::remove_file(&artifact).unwrap();
        }
        for cmd in ["vendor", "repair"] {
            let dry = exit_and_status(f.run(&[cmd, "--json", "--dry-run"], &offline));
            let wet = exit_and_status(f.run(&[cmd, "--json"], &offline));
            if dry != wet {
                disagree.push(format!("{eco}: {cmd} --dry-run {dry:?}, {cmd} {wet:?}"));
            }
        }
    }
    assert!(disagree.is_empty(), "(exit code, status) offline:\n{}", disagree.join("\n"));
}
$ cargo test -p socket-patch-cli --test <the file above>
(exit code, status) offline:
npm: vendor --dry-run (0, "success"), vendor (1, "partialFailure")
npm: repair --dry-run (0, "success"), repair (1, "partialFailure")
pnpm: vendor --dry-run (0, "success"), vendor (1, "partialFailure")
pnpm: repair --dry-run (0, "success"), repair (1, "partialFailure")
cargo: vendor --dry-run (0, "success"), vendor (1, "partialFailure")
cargo: repair --dry-run (0, "success"), repair (1, "partialFailure")
golang: vendor --dry-run (0, "success"), vendor (1, "partialFailure")
golang: repair --dry-run (0, "success"), repair (1, "partialFailure")
pypi-requirements: vendor --dry-run (0, "success"), vendor (1, "partialFailure")
pypi-requirements: repair --dry-run (0, "success"), repair (1, "partialFailure")
pylock: vendor --dry-run (0, "success"), vendor (1, "partialFailure")
pylock: repair --dry-run (0, "success"), repair (1, "partialFailure")
gem: vendor --dry-run (0, "success"), vendor (1, "partialFailure")
gem: repair --dry-run (0, "success"), repair (1, "partialFailure")
composer: vendor --dry-run (0, "success"), vendor (1, "partialFailure")
composer: repair --dry-run (0, "success"), repair (1, "partialFailure")
maven: vendor --dry-run (0, "success"), vendor (1, "partialFailure")
maven: repair --dry-run (0, "success"), repair (1, "partialFailure")
nuget: vendor --dry-run (0, "success"), vendor (1, "partialFailure")
nuget: repair --dry-run (0, "success"), repair (1, "partialFailure")
test result: FAILED. 6 passed; 1 failed

An artifact with bytes appended, in place of the deleted one, gives the same exit codes in all ten: 0 for each preview and 1 for each run.

Cause

Both previews return above the checks the run makes before it downloads anything:

  • CLI commands/vendor.rs, lines 4214 to 4217: if common.dry_run { … "wouldRedownload": true … continue; }, above the call to vendor::redownload::restore.
  • CLI commands/vendored_backend/repair.rs, lines 806 to 834: the dry-run block returns above the same call.
  • restore (core vendor/redownload.rs, line 74) first refuses a vendor directory that is a symbolic link, then an offline or client-less service (service_offline_conflict), then a JVM tree asked for from a subproject. A preview sees none of the three.

The backends ask service_offline_conflict whether or not the run is dry (core vendor/npm_common.rs, line 346; vendor/cargo.rs, lines 785 and 901), which is why the preview of a package that is not vendored yet is right.

Planned fix

One preflight in vendor::redownload holding the three refusals, which restore calls first and both dry-run blocks call too. A preview whose preflight fails records the failed event its run records (vendor_redownload_failed from vendor, vendor_artifact_redownload_failed from repair), marks the run a partial failure and exits 1. An online preview keeps wouldRedownload. The test above goes in a suite that uses vendor_ecosystem_fixtures and turns green.

Behavior change: the exit code and status of an offline dry run over a broken vendored artifact go from 0 and success to 1 and partialFailure, as the run and the two agreeing previews have them.


Generated by Claude Code

Activity

  1. added
    bug
    arch-audit
    on Nov 30, 2026
  2. added a commit that references this issue on Nov 30, 2026
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:triagedarch-auditbugpriority:p3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions