← Back to Pull requests

Only treat a Yarn cache folder with archives as an offline cache #17087

Closed
BenKamin03 closed this pull request without merging on Dec 02, 2026 01:13 UTC
View on GitHub
BenKamin03 BenKamin03 commented on Dec 02, 2026 01:09 UTC
Author

What are you trying to accomplish?

FileFetcher#create_yarn_cache (added in #11011) always runs FileUtils.mkdir_p on the Yarn cacheFolder. Helpers.yarn_offline_cache? treats any existing cache folder plus nodeLinker: node-modules as an offline cache. As a result, every Yarn Berry project using the node-modules linker runs Yarn with --mode=skip-build, which fetches every package in the lockfile, instead of --mode=update-lockfile.

This shows up in grouped updates for a project that also installs from a private registry the job has no credentials for:

1. The first dependency in the group runs yarn add <dep>@<version> --mode=skip-build, then yarn install --mode=skip-build. Both try to fetch every package, and the private registry returns 403, so the update fails with dependency_not_found.
2. Dependabot then runs git stash push --all and git clean, which removes the empty cache folder.
3. Every later dependency in the same group runs with --mode=update-lockfile, only fetches what changed, and succeeds.

So the grouped PR always leaves out whichever dependency is processed first.

This PR makes yarn_offline_cache? require at least one .zip archive in the cache folder. A project that keeps an offline cache always has archives there, so it still gets skip-build.

Anything you want to highlight for special attention from reviewers?

  • The PR description for #11011 says creating the cache folder fixed a yarn add failure, reproduced in a private repository I can't see. If that fix worked by switching those projects to skip-build, this change would revert it for them. A maintainer who can see that reproduction may want to check it.

  • Only checking that the folder isn't empty isn't enough. Yarn writes a .gitignore into its cache folder, so a folder holding only that file would still count. The new spec covers that case.

  • Dir.each_child is used instead of Dir.glob, so a cacheFolder containing glob characters is handled literally.
  • How will you know you've accomplished your goal?

  • New specs for Helpers.yarn_offline_cache? cover: no folder, empty folder, a folder holding only .gitignore, a folder with an archive, a custom cacheFolder, and a Plug'n'Play project. The empty-folder spec fails on main.

  • The existing offline-cache specs for the Yarn lockfile updater and the custom cacheFolder spec for the file fetcher still pass.

  • RuboCop and Sorbet (srb tc) report no errors on the changed files.

  • I ran the specs locally with Ruby 3.4.12, because the pinned 4.0.5 wasn't available.
  • Checklist

  • I have run the complete test suite to ensure all tests and linters pass.

  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.

  • I have written clear and descriptive commit messages.

  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.

  • I have ensured that the code is well-documented and easy to understand.
  • 🤖 Generated with Claude Code

    Diff: 401 lines (+300 / -101) across 5 files Reviewer: None requested Review duration: 4m
    All Vouch review confidence checks passed
    Residual risk 0.37 = Change Risk (0.57) × (1 − Review Confidence (0.35)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 401 lines diff across 5 files
    0.57
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 40% · Reviewer familiarity: 10%
    34%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.359
    Shallow Review Depth shallow_review_depth
    0.289
    No Reviewer Assigned no_reviewer_assigned
    0.120
    Real PR Conversation Timeline
    1 comments
    "Review active on #17087"
    general weight: 0.35
    Reviewers
    None requested
    Assignees
    BenKamin03 BenKamin03
    Labels
    risk: medium confidence: 35.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 56.7% (MEDIUM) · Higher = larger blast radius
    56.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 35.0% · Lower = rushed or shallow review
    35.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 36.9% · Moderate risk
    36.9%