Skip to content

ai/ti: describe ti fs copy-file overwrite behavior and local path rules - #24767

Open
srstack wants to merge 5 commits into
release-8.5from
ti-fs-copy-file-overwrite
Open

srstack wants to merge 5 commits into
release-8.5from
ti-fs-copy-file-overwrite

Conversation

@srstack

@srstack srstack commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What is changed, added or deleted? (Required)

ti fs copy-file gained behavior in tidbcloud/ti-cli#100 that this page does not describe, so the reference is updated:

  • --overwrite: an upload or a download overwrites the destination directly; a copy within the file system (--from-remote with --to-remote) stages the source at <destination>.ti-tmp-<id> and renames it onto the destination. The page now states the access the rename needs and the ti fs delete-file --path remedy when a failed rename leaves the temporary file behind.
  • --from-local and --to-local: state that only plain file system paths are accepted and that a URL scheme such as file:///path is rejected.
  • Adds the directory rule (<destination>/<source-file-name>), the refusal without --overwrite, and a "Replace an existing remote file" example.

Which TiDB version(s) do your changes apply to? (Required)

  • master (the latest development version)
  • v8.5 (TiDB 8.5 versions)
  • v8.4 (TiDB 8.4 versions)
  • v8.3 (TiDB 8.3 versions)
  • v8.2 (TiDB 8.2 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

The ai/ti pages exist only on release-8.5, so this change targets that branch only and does not apply to master.

What is the related PR or file link(s)?

AI agent involvement

  • The changes in this PR were primarily made by an AI agent on behalf of the PR author.

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Summary by CodeRabbit

  • Documentation
    • Clarified that --from-local and --to-local require plain filesystem paths; URL schemes such as file:///path are rejected.
    • Expanded overwrite guidance for uploads, downloads, and remote-to-remote copies, including access and cleanup considerations.
    • Explained that --overwrite has no effect with recursive copies: an existing destination root is reused, but copying stops if a path beneath it already exists.
    • Described how directory destinations resolve and documented existing-destination handling for --append, --resume, --recursive, and --layer-id.
    • Added an example of overwriting a remote file.

The ti fs copy-file reference described --overwrite in one line and did not
say what a destination that already exists means for each direction.

- --overwrite now explains that an upload or a download overwrites the
  destination directly, while a copy within the file system stages the
  source at <destination>.ti-tmp-<id> and renames it onto the destination,
  with the access the rename needs and the path to delete if a failed
  rename leaves the temporary file behind.
- --from-local and --to-local say that only plain file system paths are
  accepted; a URL scheme such as file:///path is rejected.
- The options list adds the directory rule and the without---overwrite
  refusal, and an example shows replacing an existing remote file.

Follow-up for ticloud/ti-cli#100.
@ti-chi-bot

ti-chi-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign csuzhangxc for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added missing-translation-status This PR does not have translation status info. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

The file-copy reference now documents local path requirements, destination resolution, and overwrite behavior for uploads, downloads, and remote-to-remote copies. It adds an example that overwrites a remote file.

Changes: File Copy Options

Layer / File(s) Summary
Document path and overwrite behavior
ai/ti/reference/ti-fs-copy-file.md
The reference specifies that local paths must not use URL schemes, explains destination resolution and existing-destination handling, and describes overwrite behavior for different copy modes. A new example shows replacing a remote file.

Estimated code review effort: 1 (Trivial) | ~4 minutes

Change: Other

Suggested reviewers: icemap

Merge Risk: Low · previous review cb122

The documentation is mostly accurate, but it overstates the staged-replacement guarantee for resumed copies. It also does not say that copying standard input into a directory needs an explicit destination file path. Fixing both wording gaps is a small follow-up and does not block merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two changes the page now documents: overwrite behavior and local path rules for ti fs copy-file. The raw summary confirms both, along with the directory destination rule. It omits …
Description check Passed The description covers the required sections: changes made, the affected version (v8.5 only, with rationale), related links, and AI agent involvement. Template sections such as the first-time contribu…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two changes the page now documents: overwrite behavior and local path rules for ti fs copy-file. The raw summary confirms both, along with the directory destination rule. It omits the directory rule and the new example, which is acceptable for a title.

Full details: Description check

Explanation

The description covers the required sections: changes made, the affected version (v8.5 only, with rationale), related links, and AI agent involvement. Template sections such as the first-time contributor checklist and the affected-release notes are not filled in, but the required content is present. The description is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

Additional comments: 1

ai/ti/reference/ti-fs-copy-file.md-73-73: 1

73-73: Major · Data Integrity & Integration · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Distinguish remote symlinks from directories.

A remote symlink to a directory is treated as the link itself, not as that directory. An upload with --overwrite can replace the link payload instead of writing inside the directory. Document this distinction alongside the destination rule. (github.com)

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ecad3ce and 1855b36.

Files selected for processing: 1

  • ai/ti/reference/ti-fs-copy-file.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Comment thread ai/ti/reference/ti-fs-copy-file.md Resolved
Comment thread ai/ti/reference/ti-fs-copy-file.md Resolved
…y-file

Review follow-up on the overwrite description:

- a failed staged replace leaves a temporary file that the delete-file
  remedy only removes with the same --file-system-id and a token that has
  delete access;
- --recursive does not stage or rename, and --overwrite has no effect on it;
- a download with --resume skips the destination check and replaces an
  existing local file, and --layer-id skips it too.
@srstack

srstack commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

The four CodeRabbit findings on the first revision are addressed in eb14d9659:

  • Cleanup command (file-system + token): the temporary file is deleted with ti fs delete-file --path <temporary-path>, now stating that it needs the same --file-system-id and a token that has delete access.
  • Recursive copies: --recursive does not stage or rename, and --overwrite has no effect on it; if a destination path exists, the command stops before copying anything.
  • Download --resume: it skips the destination check and replaces an existing local file, so the page now warns to protect that file before resuming.
  • --layer-id: it also skips the existing-destination check, writing to the layer and replacing any existing file at that path.

The Chinese translation is open as pingcap/docs-cn#22111 (same branch name, label translation/from-docs).

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1855b36 and eb14d96.

Files selected for processing: 1

  • ai/ti/reference/ti-fs-copy-file.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Comment thread ai/ti/reference/ti-fs-copy-file.md Resolved
Comment thread ai/ti/reference/ti-fs-copy-file.md Resolved
Second review round on the overwrite description:

- the staged sibling and rename describe a base file system destination;
  --layer-id writes directly to the layer and is not staged or renamed;
- a recursive copy reuses an existing destination root and stops only when
  a path below that root already exists;
- --append and --resume also skip the existing-destination check, so the
  paragraph now lists all four exceptions instead of two.
@srstack

srstack commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

All three are fixed in cb1222c67:

  • Recursive root vs descendant: the text now says a recursive copy reuses an existing destination root and stops only when a path below that root already exists.
  • Layer writes: the staged sibling and rename are scoped to a base file system destination; with --layer-id the copy is not staged or renamed and writes directly to the layer.
  • --append and --resume: the paragraph no longer says "two exceptions". It now lists all four checks that are skipped: --append (extends an existing remote file), --resume (continues a transfer; on a download it ignores the flag and replaces the local file), --recursive (reuses the root, stops on a conflicting descendant), and --layer-id (writes to the layer and replaces any existing file there).

The reference is a flag list, so each exception belongs in the bullet it
qualifies instead of one long paragraph:

- --append, --resume, --recursive, and --layer-id each say that the
  existing-destination check does not apply (and what that means);
- --overwrite keeps the staged copy and the access it needs in three
  sentences, with the staging-file remedy in one line;
- the paragraph after the list is back to the directory rule and the
  without---overwrite refusal, two sentences.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between eb14d96 and cb1222c.

Files selected for processing: 1

  • ai/ti/reference/ti-fs-copy-file.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

Comment thread ai/ti/reference/ti-fs-copy-file.md Resolved
Comment thread ai/ti/reference/ti-fs-copy-file.md Resolved
@srstack

srstack commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Fair complaint — the first revision read like a design note. 0c95a0569 rewrites the added text as flag bullets:

  • --append, --resume, --recursive, and --layer-id each carry the one sentence about the existing-destination check they skip; the four-case paragraph is gone.
  • --overwrite is three sentences now (what it replaces, the staged sibling + rename, the access it needs), with the staging-file remedy in one line.
  • The paragraph after the options list is back to two sentences: the directory rule and the refusal without --overwrite.
  • --from-local/--to-local say only "A URL scheme such as file:///path is not accepted."

Net: 9 changed lines, every option bullet one to three sentences, and the facts from the review rounds are kept.

- --resume, --recursive, and --layer-id skip the staging step, so the
  one-step replacement does not apply to them;
- --from-stdin needs an explicit destination file path, because a
  directory destination has no file name to use.
@srstack

srstack commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Both are fixed in 807389e5c, in one sentence each:

  • --overwrite: "--resume, --recursive, and --layer-id skip the staging step." The one-step replacement therefore does not apply to --overwrite --resume.
  • --from-stdin: "Specify an explicit destination file path; a directory destination is not accepted."

@qiancai qiancai self-assigned this Nov 25, 2026
@qiancai qiancai added translation/no-need No need to translate this PR. area/tidb-cloud This PR relates to the area of TiDB Cloud. labels Nov 25, 2026
@ti-chi-bot ti-chi-bot Bot removed the missing-translation-status This PR does not have translation status info. label Nov 25, 2026
@qiancai

qiancai commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

/hold

@ti-chi-bot ti-chi-bot Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tidb-cloud This PR relates to the area of TiDB Cloud. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. translation/no-need No need to translate this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants