Skip to content

rtk proxy rg silently corrupts matched text: replaces "cypress" with "n" #4212

Closed as not planned

Description

@Valentin-B117

Environment

  • rtk version: 0.42.4 (rtk --version → rtk 0.42.4)
  • OS: macOS (Darwin, arm64)
  • Invocation: rtk proxy <cmd> — documented as "Execute raw command without filtering (for debugging)"

Summary

rtk proxy rg returns search results where the literal (lowercase) substring
cypress has been replaced with n throughout the output — not filtered
out, not truncated, silently rewritten. This happened even though
rtk proxy is documented to run the raw command "without filtering." The
corruption is invisible unless you already know the file content and notice
it looks wrong.

Steps to reproduce

  1. In a repo containing .github/workflows/lint_and_test.yaml with lines like:
    image: cypress/browsers:node-22.21.0-chrome-...
    - run: pnpm exec cypress install
    - name: run cypress components tests
      uses: cypress-io/github-action@...
    - name: upload cypress videos
        name: cypress-videos
        path: tests/e2e/cypress/videos
  2. Run:
    rtk proxy rg -rn "cypress" .github/workflows
    
  3. Compare against the file's real content (e.g. via cat or any tool that bypasses rtk).

Expected

Output matches the real file content byte-for-byte (that's the whole point
of proxy mode): cypress, cypress-io, cypress/browsers, cypress.config.js
etc. appear as they are on disk.

Actual

Every case-sensitive, lowercase occurrence of cypress is replaced with n,
including inside compound identifiers:

.github/workflows/lint_and_test.yaml:  n:
.github/workflows/lint_and_test.yaml:      image: n/browsers:node-22.21.0-chrome-...
.github/workflows/lint_and_test.yaml:      - run: pnpm exec n install
.github/workflows/lint_and_test.yaml:      - name: run n components tests
.github/workflows/lint_and_test.yaml:        uses: n-io/github-action@...
.github/workflows/lint_and_test.yaml:      - name: run n
.github/workflows/lint_and_test.yaml:      - name: upload n videos
.github/workflows/lint_and_test.yaml:          name: n-videos
.github/workflows/lint_and_test.yaml:          path: tests/e2e/n/videos
.github/workflows/cypress_tests.yaml:name: n tests prod
.github/workflows/cypress_tests.yaml:        uses: n-io/github-action@...
.github/workflows/cypress_tests.yaml:          # https://docs.n.io/guides/cloud/projects#Set-up-a-project-to-record
.github/workflows/cypress_tests.yaml:          # No baseUrl override: n.config.js derives it from WEB_BASE_URL...
.github/workflows/cypress_tests.yaml:        subject: "n tests result (see https://cloud.n.io/projects/5y5tn5 for details):"

A direct read of the same file (bypassing rtk entirely) confirms the real
text: cypress/browsers, cypress install, cypress components tests,
cypress-io/github-action, cypress-videos, docs.cypress.io,
cypress.config.js, cloud.cypress.io, etc. Capitalized instances
("~/.cache/Cypress", "Cypress") were not corrupted, which suggests
this is a literal case-sensitive find/replace of the string cypress → n
somewhere in rtk's output path, not a filename-shortening or path-aliasing
feature working as intended.

Impact

This is silent data corruption of tool output, not a formatting or
token-savings tradeoff. It's indistinguishable from a real answer unless the
caller happens to cross-check against the source file. In an agentic
workflow, this can lead to wrong conclusions being drawn from search
results, wrong code being written or suggested based on "what the file
says," and it undermines trust in every other rtk-mediated read once
found.

Related (secondary) observation

Separately, letting rtk auto-rewrite a plain rg invocation (not via
proxy) into a grep call broke outright on flags rg supports but grep
doesn't (-g '!pattern', --type), e.g.:

grep: invalid option -- g
grep: unrecognized option `--type'

That's a correctness bug too (silently changing which flags a command
"supports" mid-invocation), but it at least fails loudly. The cypress → n
corruption above is the more serious issue because it fails silently and
returns a plausible-looking wrong answer instead of erroring.

Suggested fix

At minimum, rtk proxy should guarantee byte-identical passthrough of the
underlying command's stdout/stderr — that's its stated purpose. If there's
some intentional dictionary-based output compression for token savings, it
must not be applied under proxy, and even outside proxy it needs to be
reversible/lossless for the caller, not a silent lossy substitution.

Activity

  1. desty commented on Oct 16, 2026

    @desty

    I think this comes from ripgrep rather than rtk. In rg, -r is --replace and takes a value, so -rn parses as -r n, i.e. "replace every match with n". This is different from grep -rn, where it means recursive plus line numbers.

    The same thing reproduces with plain ripgrep (14.1.1), no rtk involved:

    $ printf "image: cypress/browsers:node-22\n- run: pnpm exec cypress install\npath: ~/.cache/Cypress\n" > wf.yaml
    $ rg -rn "cypress" wf.yaml
    image: n/browsers:node-22
    - run: pnpm exec n install
    $ rg -n "cypress" wf.yaml
    1:image: cypress/browsers:node-22
    2:- run: pnpm exec cypress install
    

    This also explains the other details in the report:

    • There are no line numbers in the output, because n was consumed as the replacement and -n was never applied.
    • Only lowercase cypress changed, because the search is case-sensitive.

    rtk bypass/rtk proxy streams the child output byte for byte (Commands::Bypass in src/lib.rs), and rtk's search code already treats -r as taking a replacement value for rg (see the extract_pattern_path tests in src/cmds/system/search.rs). rg -n "cypress" gives the intended output, since ripgrep searches recursively by default.

    The secondary observation about a rewritten rg call losing -g/--type looks like a separate issue.

  2. KuSh commented on Oct 31, 2026

    @KuSh
    Collaborator

    Closing, as this is ripgrep's behaviour, as explained above: in rg, -r is --replace and takes a value, so -rn "cypress" replaces every match with n. Plain ripgrep does the same (rg -rn cypress wf.yaml prints image: n/browsers), and rtk proxy passes the output through unchanged. rg -n "cypress" gives line numbers, and ripgrep searches recursively by default.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions