Repository navigation
fix: drop redacted file rows that collide with a directory in the tree - #17460
iamwhatever wants to merge 1 commit into
Conversation
When /api/project/tree redaction falls back to the whole-string result (a match straddling a /), deep paths collapse onto one shorter string, so a redacted file row can equal a directory row or become another file's parent. @pierre/trees throws "Path collides with an existing entry" on a name that is both, uncaught inside the tree's layout effect, crashing the whole chat route. _project_tree_body now drops such a file row after the per-list de-dup (_project_tree_drop_file_directory_collisions), keeping the directory row (the collapsed file has no real path left to open). On an unredacted listing one name is one inode, so the filter never bites. The frontend half of the original PR (#13580) is already on main via dedupeTreePaths (#14077); this ports only the still-missing server-side guard onto the relocated file_api/project_tree.py module.
First Principles Review (Opus 5.5) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK The backend filter re-implements Not justified as shipped
What this change shipsInventory (4 items) — 1 justifiedIntent: stop a redacted path collision from crashing the chat route's file tree. This is a FIX.
Blockers
[FIRST-PRINCIPLES-REVIEWED] 2a93bee Description read[DESCRIPTION-READ] d70607a8f5ae211b97ad006ccd9e6e791b6bdb496719ef80b13a56bd680e5295 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS There's no evidence the crash still happens on Watch
[DESIGN-REVIEWED] 2a93bee Description read[DESCRIPTION-READ] 7935b66e4e9d94cd4511c1d5986e5161925ede91fe5f792af93a92794dd81d1a That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
Closing: the crash this targeted is already fixed on |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Problem / Motivation
Goal: stop
GET /api/project/treefrom returning a redacted file row that collides with a directory row, which crashes the whole chat route.Opening a chat whose project directory holds one particular path shape crashes the entire route with
Error: Path collides with an existing entry: "<dir>/<prefix>-[REDACTED: credential]", thrown inside the tree'suseLayoutEffectand caught by nothing. The Files rail, the folder tab and the chat all go down with 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 one secret (e.g. a case-id segment of digits followed by camel-case package segments, ~43 chars with slashes in it). The user gets no tree, no folder panel and no chat for that project until they find and rename the directory, with no hint which one is at fault.
Not a goal
Not loosening the bare-secret detector's slash cap: that is a measured trade-off against real 40-char keys, and the tree must not crash on whatever the redactor returns regardless. Not fixing the separate
+/=byte-sort-vs-segment-sort ordering crash tracked in #14289 (same error string, different root cause). Not changing the frontend: its half already landed onmainviadedupeTreePaths(#14077).What changed (motivation → approach → change)
Symptom: a redacted file row and a redacted directory row reach
@pierre/treeswith the same name; the tree models a name as one or the other and throws on the second.Root cause:
_project_tree_body(insrc/kiro_crew/dashboard/file_api/project_tree.py) redacts every listed path withredact_path_segments. When the whole-string credential pass matches a run that spans/, the helper falls back to the whole-string result, so every deep path under that run collapses onto one shorter string such asnotes/case-[REDACTED: credential]. The function then de-duplicatespathsanddirectorieseach on its own, so a collapsed file row and a collapsed directory row can both survive with the same name, or a collapsed file row can become the proper parent of another file row.Change:
_project_tree_bodydrops a redacted file row that equals a directory row, or that is a proper parent of another file row, after the per-list de-dup (_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 bites.dashboard/handlers/filesfacade (the composition contract), so the composed function resolves it.docs/system-specs/modules/learn-cron-dashboard.mdrecords the rule.This ports the backend half of #13580 by @coolpistachio (Sergio Ramirez Martinez), with credit — the fix commit keeps their authorship.
api_project_treemoved tofile_api/project_tree.pyin #16758 and the redaction moved into_project_tree_bodyin #16029, so the original PR's target (dashboard/handlers/files.py) no longer holds this code; the frontend half already landed onmainvia #14077.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.test/test_project_tree.py(64) green;test/test_dashboard_files_composition_contract.py(84) green;mypy src/kiro_crew/dashboard/file_api/project_tree.py,isort,flake8,scripts/docs-lint.shall clean.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).
Fixes #17459