Skip to content

fix(id): confine REPL match-derived download paths (#2307) - #4472

Merged
dezren39 merged 2 commits into
mainfrom
queue/5238-2307-repl-download-paths
Nov 2, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/5238-2307-repl-download-paths

Conversation

@dezren39

@dezren39 dezren39 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #2307

Verification


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 2, 2026 17:02
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 789f7f01-242c-4305-bed9-3f83c345c1ee
Commits

Reviewing files that changed from the base of the PR and between 997ee1d and b61edc3.

Files selected for processing: 4
  • pkgs/id/src/commands/find.rs
  • pkgs/id/src/helpers.rs
  • pkgs/id/src/lib.rs
  • pkgs/id/src/repl/runner.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T17:13:19.040360Z b61edc3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12a8dc51db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Explicit user path stays the user's choice.
Some(path) => path.to_owned(),
// Match-derived default: confine via the shared CLI ruling.
None => download_output_path(None, &m.name)?,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep derived filenames distinct from the stdout sentinel

When a match is named nested/-, find nested/- --file now reduces its destination to -. ReplContext::get forwards that value to export_blob, whose output == "-" branch (pkgs/id/src/lib.rs:569) writes the content to stdout instead of saving a file. Previously, nested/- was treated as a literal file path. The same regression affects search --file and interactive match-derived file outputs. Represent the derived filename as ./- or otherwise distinguish it from the stdout sentinel, while preserving explicit user-supplied - behavior.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b61edc3: download_output_path now returns ./- for a match-derived bare - (no-dir case), so derived filenames never collide with the stdout sentinel in export_blob; explicit user-supplied - is untouched. Regression test test_download_output_path_dash_name_is_not_the_stdout_sentinel covers -, nested/-, and the dir case.

Comment on lines +1226 to +1231
if let Some(previous) = destinations.insert(output_path.clone(), m.name.as_str()) {
println!(
"refusing bulk download: destination collision between matches {:?} and {:?} at {:?}",
previous, m.name, output_path
);
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Deduplicate identical matches before checking selected destinations

When overlapping queries return the same match, selecting both displayed entries now refuses the entire download even though they reference identical content and the same name. For example, find report txt --dir downloads can list report.txt twice because collect_matches appends results independently for each query and apply_search_options does not deduplicate them; selecting both entries reaches this collision branch and writes nothing. Previously that selection succeeded, and the updated --all path already avoids this problem by deduplicating (hash, name) before checking destinations. Apply that deduplication to interactive directory and default-file output too, while continuing to reject collisions between distinct matches.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b61edc3: both interactive paths (output_selected_matches_to_dir and the interactive --file preflight) now deduplicate identical (hash, name) matches before the destination-collision check, matching the --all path; collisions between distinct matches are still refused as a batch. Regression test test_interactive_dir_duplicate_identical_selections_fetch_once covers selecting the same match twice.

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

Labels

None yet

Projects

None yet

1 participant