Repository navigation
fix: drop redacted file rows that collide with a directory in the tree - #13580
coolpistachio wants to merge 1 commit into
Conversation
The workspace tree crashed a whole chat route with "Path collides with an existing entry" from @pierre/trees. The project-tree endpoint redacts every listed path before egress, and when the whole-string match spans a "/" (a bare-secret run made of a digit-heavy segment plus camel-case segments, at most three slashes), every path under that run collapses onto one shorter string. The endpoint de-duplicated files and directories separately, so a collapsed FILE row and a collapsed DIRECTORY row with the same name both reached the tree builder, which throws on a name that is both, uncaught inside the layout effect. The endpoint now drops a redacted file row that equals a directory row or is a proper parent of another file row; the collapsed file has no real path left to open, while the directory may still carry children. The frontend applies the same rule to the merged path set before resetPaths, so an older gateway cannot crash a newer dashboard. The owning spec paragraph records the rule.
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
5 similar comments
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
PR triage (automated, diff-level): PARTIALLY_COVERED by merged #14077. Please rebase. I compared this PR's diff (merge base Already on main (frontend half): #14077 (PR, merged 2026-10-02) added Not on main (backend half): main has no server-side equivalent of Suggested next step: rebase onto main and drop the I found no breaking change and no P0 bug. |
|
Thank you for this, @coolpistachio — the root-cause write-up on the redaction collapse was excellent and made the problem easy to confirm. Since you opened this, the crash was fixed on Your backend |
Problem / Motivation
Opening a chat whose project directory holds one particular path shape crashes the whole route with:
The Files rail, the folder tab and the chat itself go with it, because the throw happens inside the tree's
useLayoutEffectand nothing catches it.Why it matters
Any workspace can trigger it by containing a directory whose name plus its children form a base64-alphabet run the redactor treats as a secret. In my case a notes folder named after a case id, with two vendored packages cloned under it, was enough. The user gets no tree, no folder panel and no chat for that project until they find and rename the directory, and the error gives no hint which one.
What changed (motivation → approach → change)
Symptom: a file row and a directory row with the same name reach
@pierre/trees, which models a name as one or the other and throws on the second.Root cause:
/api/project/treeredacts every listed path withredact_path_segments. When the whole-string credential pass matches a run that spans/(here: a case-id segment of digits followed by camel-case package segments, 43 chars, three slashes, which clears the bare-secret gates), the helper falls back to the whole-string result, so every path under that run collapses onto one shorter string such asnotes/case-[REDACTED: credential]. The endpoint then de-duplicatedpathsanddirectoriesseparately, so a collapsedConfigfile and a collapseddocs/plansdirectory both survived, with the same name.Change:
api_project_treedrops a redacted file row that equals a directory row, or that is a proper parent of another file row (_project_tree_drop_file_directory_collisions). The file row is the one to drop: its real path is gone, so nothing could open it, while the directory may still carry visible children. On an unredacted listing one name is one inode, so the filter never touches a real path.PierreWorkspaceTreeImplapplies the same rule to the merged path set beforeresetPaths, next to the existing duplicate de-dup, so an older gateway cannot crash a newer dashboard.docs/system-specs/modules/learn-cron-dashboard.mdrecords the rule.I left the bare-secret detector alone. Its slash cap is a measured trade-off against real 40-char keys, and loosening it to save a tree row is not this PR's call; the tree must not crash on whatever the redactor returns.
Backwards compatibility
Compatible: the response shape is unchanged; the only difference is that a redacted file path which the tree could not represent (and no client could open) is absent from
paths. Unredacted listings are byte-identical.Tests
test/test_project_tree.py::test_a_file_that_redacts_onto_a_directory_row_is_dropped: the collapsed name stays a directory row, leavespaths, neighbours keep their rows, andpaths ∩ directoriesis empty.test/test_project_tree.py::test_a_file_that_redacts_onto_another_files_parent_is_dropped: the other shape, where the collapsed file is a parent of a deeper file.website/src/test/PierreWorkspaceTreeImpl.test.tsx"drops a file row whose name is also a directory before it reaches the model": the wrapper handsresetPathsa set with no file/directory name clash.All three fail on
mainand pass with the change.Manual verification
api_project_treewith the real redactor: 200, 45 redacted entries, no file row equal to a directory row or to another file's parent; with the new filter neutralized the same run reports the one colliding string from the stack trace above.python3 scripts/local-gate.py(related tests, both surfaces): frontend set 535 files / 14,133 tests green; backend sets 40,011 + 35,638 green with 61 + 15 failures that reproduce identically onmainin this environment (a checkout and pytest basetemp under the agent's~/.kiro/crew/scratch, which the file-explorer and design-tweak apps refuse as a sensitive path; norgon the host;ssh -Gon a data-home path; Playwright installer), plus one pty SIGINT terminal test that passed when re-run alone on both trees. None of them import the changed handler.check_black_formatting.py,check_subprocess_encoding.py,isort,flake8,mypy src/kiro_crew,scripts/docs-lint.sh,check_harness_parity.py,npx tsc -p tsconfig.app.json,eslint --max-warnings 0on the two touched frontend files.Screenshots / video
Why no screenshot: the change removes a crash; a listing that rendered before renders identically, and the listing that crashed now renders the ordinary tree with one inert redacted file row absent.
Related Issues
N/A — no open issue; the report and the reproduction are in this PR.
Pattern harvest
Rule candidate: review-prompt
Pattern: a list de-duplicated per collection is handed to a consumer whose invariant spans the collections (a file name and a directory name share one namespace)
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement