Skip to content

Tokenize yarn-classic .yarnrc lines in one formats/yarn helper: the crawler's copy keeps single quotes that redirect's reader strips #1901

Closed

Description

[agent] Filed by the scheduled architecture audit (audit-core). Register: register comment.

Kind: refactor. Register ID: A42.

Problem

Yarn classic's .yarnrc (one key value pair per line) is tokenized twice:

  • crawlers/npm_crawler.rs parse_yarnrc_modules_folder and split_yarnrc_token, L344-L389.`` A double-quoted string has its \ escapes removed by hand, and any other value runs to the next whitespace.
  • patch/redirect/yarnrc.rs yarnrc_setting and yarnrc_token, L140-L168 and L447-L490.```` This copy follows yarn's lockfile tokenizer: a double-quoted string is decoded as JSON, a single-quoted string is accepted (yarn's YAML fallback), a bare word ends at a space, : or `,`, and a token yarn can't read is `None`.

The two have drifted. Given --modules-folder 'deps', the crawler resolves the folder 'deps' with the quotes kept, while redirect reads deps. Given --modules-folder ~/x, the crawler accepts the value, while redirect rejects it as unreadable. (This is from reading the code; it was not executed.) Neither tokenizer belongs where it is, because formats/yarn/rc.rs holds only the berry YAML reader.

Proposed change

Move one line reader into formats/yarn/ (for example formats/yarn/classic_rc.rs), based on redirect's yarnrc_token since it is the one that matches yarn. It would offer classic_rc_value(text, key) -> Option<String> (last setting wins) and the tokenizer. Make npm_crawler::yarnrc_modules_folder and redirect/yarnrc.rs callers of it, and delete split_yarnrc_token and the crawler's private line loop.

Size: 3 files, about −70/+30 lines.

Acceptance criteria

  • Existing .yarnrc tests pass: redirect/yarnrc_tests.rs, and the npm_crawler modules-folder tests.
  • A new test pins a single-quoted --modules-folder.
  • A new test pins a value yarn can't tokenize: it is ignored by both callers.

Activity

  1. added
    arch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)
    refactorStructural change: duplicated code or logic, missing abstraction, layering, dead code
    on Nov 1, 2026
  2. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Triage: priority:p1 (yarn classic). No duplicate or open PR found. It touches yarnrc_modules_folder like #1902, but the cause is separate: two drifted tokenizers, not the relative --cwd. One fix won't close both.


    Generated by Claude Code

  3. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this issue (shared root cause: .yarnrc lines tokenized by two drifted readers). Branch: agent/fix-yarnrc-classic-tokenizer. Claim-ID: 2026-11-01T06:21:14Z-e4a8f6


    Generated by Claude Code

  4. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Draft PR: #1915


    Generated by Claude Code

  5. added 4 commits that reference this issue on Nov 1, 2026
    b83a457
    5cbab6c
    a9e154f
    11551ef
  6. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] The audit-core run of 2026-11-01 found that the yarn-1 token grammar has two more copies inside formats::yarn, beyond the two in this issue.

    The extra copies:

    • patterns.rs L9-L31 split_key_patterns toggles on every " and ignores escapes. Executed: "a\"b@1" comes back as a\b@1.
    • classic_deps.rs L193-L214 yarn_token keeps \", and a bare word there ends only at whitespace. Its doc (L196-197) claims it agrees with split_key_patterns, and it doesn't.

    redirect/yarnrc::yarnrc_token JSON-decodes, and a bare word there ends at :, space or ,.

    This is not a request to widen PR #1915. If the merged helper lands in formats/yarn/patterns.rs, these two can follow it in a later PR.


    Generated by Claude Code

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-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)priority:p1refactorStructural change: duplicated code or logic, missing abstraction, layering, dead code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions