You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(folders): cleanup pass + fix stale cycle-check race in workflow folder update
Cleanup pass over the remaining audit findings (dead code, stale comments,
duplicated logic, minor hygiene), plus two real bugs caught along the way:
- workflow folder-lifecycle.ts: performUpdateFolder had the same stale
cycle-check race already fixed in the generic kb/table path -- the
circular-reference check ran against an unlocked pre-transaction snapshot,
so two concurrent moves (A under B, B under A) could each pass and commit
a persisted cycle. Re-check inside the transaction now, matching the
generic path. (Caught by Greptile on the post-audit re-review.)
- folders/orchestration.ts: performUpdateFileFolder was swallowing
ResourceLockedError into a generic 500 instead of propagating it for the
route's 423 handling, unlike its create/delete/restore siblings.
- knowledge/[id]/route.ts: the admin-lock-permission check for PUT only
verified admin on the KB's *current* workspace, even though workspaceId
and locked can change in the same request -- now checks both current and
target workspace.
Other fixes: extracted duplicated lock+recheck-parent logic in
folders/orchestration.ts into a shared helper; removed dead `validUpdates`
aliases; removed dead `color` field from workflow folder params; fixed
stale comments claiming `locked`/file-folder locking is workflow-only or
unused (the generic lock engine treats all four resourceTypes uniformly);
added resourceType scoping to log folder-descendant expansion; fixed an
O(n*m) descendant-collection loop in the files-download route to build its
parent->children index once; added typed TableInvalidFolderError instead of
string-matching error messages; fixed a hardcoded SQL column literal in
pinned-items lookups; deduplicated FolderResourceType between the folders
contract and the folders store; derived a magic query-key array index from
the key factory instead of a literal; moved a render-time ref mutation in
files.tsx into an effect; memoized a per-render Object.fromEntries in
knowledge.tsx; fixed recently-deleted.tsx passing no resourceType on file
folder restore (silently defaulted to workflow); aligned a stray
eslint-disable in tables.tsx with its file/knowledge siblings.
Fixed a knowledge-route test whose hand-rolled db mock had no `transaction`
stub (needed after createKnowledgeBase was wrapped in a transaction to
close its own folder-lock TOCTOU window) and whose beforeEach was
clobbering that stub every test.
0 commit comments