Skip to content

filesystem: add scoped token denials and exit codes to troubleshooting - #23966

Merged
ti-chi-bot[bot] merged 2 commits into
release-8.5from
fix-filesystem-troubleshooting-page
Sep 30, 2026
Merged

ti-chi-bot[bot] merged 2 commits into
release-8.5from
fix-filesystem-troubleshooting-page

Conversation

@seominjea1942

@seominjea1942 seominjea1942 commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

What is changed, added, or deleted? (Required)

Three fixes, measured with ti 0.2.4 on macOS 14.6, region aws-us-west-2, 2026-09-27.

1. No entry for a scoped token denial, which is the first failure a delegated user or an agent hits.

Across 25 denied combinations of command, path, and scope, every one exits 1, and the message splits by command rather than by path. Eight commands (list-files, read-file, delete-file, create-directory, move-file, describe-file, find-files, search-file-content) report fs access denied. copy-file reports an empty HTTP 403: when uploading to, downloading from, or copying to an out-of-scope path, and fs access denied when copying from one.

The empty 403 gives the reader nothing and looks like a network fault. The new section says both messages mean the same thing, and adds two rules that are easy to miss: search requires read, and a scoped token cannot list the root unless its allowed path is /. The uneven message itself is a CLI issue, which I am filing separately.

2. The docset never states the exit codes, so automation has to match error strings instead. ti fs uses six, counted across every command in my local log, over 900 runs. The new table gives each code, its meaning, and the action.

Codes 1 and 4 both look like permission problems: 1 is a data-path denial the caller can often fix, 4 means the account lacks the permission. A new paragraph also notes that a deleted or disabled token fails with invalid API key and exit 1 rather than an authentication error, so readers stop checking API keys that were never involved.

I scoped the table to ti fs, because ti-cli-reference.md documents 130 for an interrupted ti configure. If you would rather have one list for the whole CLI, I can move the table there and leave a link here.

3. Two dense paragraphs in "File system token is rejected", one of which carried the whole fs.token_refresh_ambiguous case in a single sentence. Regrouped into one paragraph per job, keeping every fact.

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

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 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 tidb-cloud-filesystem docset exists only on release-8.5, so no other branch applies.

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 how legacy, deleted, disabled, and recently changed tokens can affect authentication and command results.
    • Added guidance for diagnosing scoped-token access denials, including path and operation requirements.
    • Added an exit-code reference distinguishing data access denials from account permission failures.

Clarified token usage instructions and exit codes for better understanding.
@ti-chi-bot ti-chi-bot Bot added contribution This PR is from a community contributor. missing-translation-status This PR does not have translation status info. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 27, 2026
@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The filesystem troubleshooting guide covers token validity and refresh outcomes, scoped-token denials, and exit codes 0–5.

Changes

Filesystem troubleshooting

Layer / File(s) Summary
Token errors, scope denials, and exit codes
tidb-cloud-filesystem/filesystem-troubleshooting.md
Clarifies token-list and refresh edge cases, explains scoped-token denials and scope requirements, and defines exit codes 0–5.

Priority: ⬇️ Low

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

Change: Other

Merge Risk: 🔵 Low · up to e80ee

The new guide gives the wrong exit codes for scoped HTTP 403 and invalid-token HTTP 401 failures, potentially misdirecting troubleshooting and scripts that rely on those codes. Correcting both mappings is localized; runtime behavior is unchanged.

Architecture Summary

Architecture risk: 🔵 Low · up to e80ee

The change affects 1 system.

Changed systems: tidb-cloud-filesystem

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — tidb-cloud-filesystem (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in tidb-cloud-filesystem/filesystem-troubleshooting.md: The token guidance clarifies that legacy credentials without lifecycle metadata may remain valid but have no list row, retains the roughly 10-second cache convergence period, and explains that an ambiguous refresh leaves the old token’s validity unknown and the replacement unrecoverable. It also documents that a deleted or disabled token can cause invalid API key with exit code 1 despite correct API keys.
  • observed — Modified behavior in tidb-cloud-filesystem/filesystem-troubleshooting.md: Adds guidance that scoped-token denials exit 1 and may report fs access denied or, for ti fs copy-file, an empty HTTP 403:. It says these messages indicate an operation or path outside token scope, not connectivity or token invalidity; directs users to compare scope with the requested operation and path; notes that search requires read, root listing requires scope /, and scoped permissions cannot be widened.
  • observed — Modified behavior in tidb-cloud-filesystem/filesystem-troubleshooting.md: Adds an exit-code reference for codes 0–5, distinguishing runtime or remote errors, local usage/configuration errors, authentication failures, account permission failures, and missing resources. It clarifies that scoped-token denials use code 1 rather than 4, nonexistent paths inside a file system use 1 rather than 5, and deleted or disabled tokens use 1 rather than 3.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main documentation changes: scoped token denials and filesystem exit codes.
Description check ✅ Passed The description is complete and follows the required template. It explains the changes, affected v8.5 version, references, AI involvement, and applicable change categories.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot

ti-chi-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown

@guangleibao: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@qiancai qiancai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rest LGTM


Then retry the token operation. A mount on another machine is not visible locally; coordinate rotation with that machine separately.

## Scoped token is denied

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
## Scoped token is denied
## Scoped token access is denied


## Scoped token is denied

A scoped token that is used beyond its scope fails with exit code 1, and the message is one of two. Most commands report `fs access denied`. `ti fs copy-file` often reports an empty `HTTP 403:` instead.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
A scoped token that is used beyond its scope fails with exit code 1, and the message is one of two. Most commands report `fs access denied`. `ti fs copy-file` often reports an empty `HTTP 403:` instead.
A scoped token used outside its scope causes the command to exit with code 1 and report one of two messages. Most commands report `fs access denied`. `ti fs copy-file` can report an empty `HTTP 403:` instead.


A scoped token that is used beyond its scope fails with exit code 1, and the message is one of two. Most commands report `fs access denied`. `ti fs copy-file` often reports an empty `HTTP 403:` instead.

Both messages mean the same thing: the token does not allow this operation on this path. Neither one is a connectivity problem or a sign that the token is invalid. Check what the token allows before you change anything:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Both messages mean the same thing: the token does not allow this operation on this path. Neither one is a connectivity problem or a sign that the token is invalid. Check what the token allows before you change anything:
In this context, both messages indicate that the token does not allow this operation on this path. Neither one is a connectivity problem or a sign that the token is invalid. Check what the token allows before you change anything:

--output text
```

Compare the token scope with the path and the operation you used. `search` also requires `read`. A scoped token cannot list the file system root unless its allowed path is `/`. A scoped token cannot widen its own permissions, so generate a new one with the operations you need instead of trying to change the existing token.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Compare the token scope with the path and the operation you used. `search` also requires `read`. A scoped token cannot list the file system root unless its allowed path is `/`. A scoped token cannot widen its own permissions, so generate a new one with the operations you need instead of trying to change the existing token.
Compare the token scope with the path and the operation you used. `search` also requires `read`. A scoped token cannot list the file system root unless its allowed path is `/`. A scoped token cannot widen its own permissions, so use an owner token to generate a new scoped token with the operations you need instead of trying to change the existing token.

| Code | Meaning | What to do |
| --- | --- | --- |
| 0 | Success | Continue. |
| 1 | The request was valid and the runtime or the service refused it | Read the message. A scoped token denial, a missing payment method, and a display name conflict all land here. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
| 1 | The request was valid and the runtime or the service refused it | Read the message. A scoped token denial, a missing payment method, and a display name conflict all land here. |
| 1 | Runtime or remote API error | Read the message and address the reported runtime, network, or service error. Scoped token denials and some other service errors also use this code. |

ref: https://github.com/tidbcloud/ti-cli/blob/main/docs/spec/done/0004-api-client-auth-and-region-routing.md?plain=1#L133

| 1 | The request was valid and the runtime or the service refused it | Read the message. A scoped token denial, a missing payment method, and a display name conflict all land here. |
| 2 | The command or the profile configuration cannot be used | Fix the command or the profile. Unknown flag, missing required input, a region where `ti fs` is unavailable, or a token file with loose permissions. |
| 3 | Authentication failed | Check the token or the API key pair. |
| 4 | The account lacks permission for the operation | Ask an organization administrator. This is different from the data-path denial at 1. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
| 4 | The account lacks permission for the operation | Ask an organization administrator. This is different from the data-path denial at 1. |
| 4 | The account lacks permission for the operation | Ask an organization administrator. This is different from a scoped-token denial, which returns exit code 1. |

Reason: "Data-path denial" is implementation-oriented terminology.

| 4 | The account lacks permission for the operation | Ask an organization administrator. This is different from the data-path denial at 1. |
| 5 | The file system, token, or other resource named in the request does not exist | Check the ID. A path that does not exist inside a file system returns 1, not 5. |

One case does not follow the table. A deleted or disabled token is reported on the data path, so it exits 1 rather than 3. See [File system token is rejected](#file-system-token-is-rejected).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
One case does not follow the table. A deleted or disabled token is reported on the data path, so it exits 1 rather than 3. See [File system token is rejected](#file-system-token-is-rejected).
A deleted or disabled file system token is an exception to the preceding table: file commands return exit code 1 rather than 3. See [File system token is rejected](#file-system-token-is-rejected).

| --- | --- | --- |
| 0 | Success | Continue. |
| 1 | The request was valid and the runtime or the service refused it | Read the message. A scoped token denial, a missing payment method, and a display name conflict all land here. |
| 2 | The command or the profile configuration cannot be used | Fix the command or the profile. Unknown flag, missing required input, a region where `ti fs` is unavailable, or a token file with loose permissions. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
| 2 | The command or the profile configuration cannot be used | Fix the command or the profile. Unknown flag, missing required input, a region where `ti fs` is unavailable, or a token file with loose permissions. |
| 2 | Local usage, validation, or configuration error | Fix the command or the profile. Examples include an unknown flag, missing required input, an unsupported region, or a token file with loose permissions. |

ref: https://github.com/tidbcloud/ti-cli/blob/main/docs/spec/done/0004-api-client-auth-and-region-routing.md?plain=1#L133

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 28, 2026
@ti-chi-bot

ti-chi-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-09-28 09:36:26.660364201 +0000 UTC m=+615911.885585308: ☑️ agreed by qiancai.

@seominjea1942

Copy link
Copy Markdown
Collaborator Author

@qiancai applied all eight suggestions. The exit code descriptions now follow the CLI spec you linked, which also confirms code 5 as remote resource not found. Renaming the heading to "Scoped token access is denied" changes its anchor, and I checked that nothing in the Filesystem or ti CLI docsets links to the old one. Ready for merge when you are. cc @guangleibao

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Document the token error as exit code 3. · filesystem-troubleshooting.md:62-63

tidb-cloud-filesystem/filesystem-troubleshooting.md:62-63
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Document the token error as exit code 3.

When a deleted or disabled filesystem token causes an HTTP 401, the v0.2.4 CLI maps the response to exit code 3. Filesystem-specific bearer-auth handling changes the message, but does not remap the status to exit code 1.

Suggested fix
-If a file command reports `invalid API key` and exit code 1 while you are passing a file system token, check the token status before you look at your API key pair. A deleted or disabled token produces this message even when the API key pair is correct.
+If a file command reports `invalid API key` and exit code 3 while you are passing a file system token, check the token status before you look at your API key pair. A deleted or disabled token produces this message even when the API key pair is correct.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: pingcap/docs/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: b1ddbe39-93e9-4924-8755-57acd95449da

📥 Commits

Reviewing files that changed from the base of the PR and between 9f6a792 and e80ee05.

📒 Files selected for processing (1)
  • tidb-cloud-filesystem/filesystem-troubleshooting.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 tidb-cloud-filesystem/filesystem-troubleshooting.md
@ti-chi-bot

ti-chi-bot Bot commented Sep 30, 2026

Copy link
Copy Markdown

@qiancai: Your lgtm message is repeated, so it is ignored.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@qiancai

qiancai commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

/approve

@qiancai qiancai added the lgtm label Sep 30, 2026
@ti-chi-bot

ti-chi-bot Bot commented Sep 30, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiancai

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

The pull request process is described 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 the approved label Sep 30, 2026
@ti-chi-bot
ti-chi-bot Bot merged commit 261fa74 into release-8.5 Sep 30, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved area/tidb-cloud This PR relates to the area of TiDB Cloud. contribution This PR is from a community contributor. lgtm needs-1-more-lgtm Indicates a PR needs 1 more LGTM. size/M Denotes a PR that changes 30-99 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.

3 participants