fix(dev-ui): guard extraction session load on tenant readiness#788
Conversation
loadExtractionSession() was the only data loader on the graph
management page missing the hasTenant.value guard that every sibling
loader (loadKgIdentity, loadWorkspaceStatus, loadOverviewMetrics,
loadArchivedWriteCount, loadGraphManagementDataSources,
refreshDesignArtifacts) already has. On a hard refresh of
/knowledge-graphs/{id}/manage?step=graph-management, the page's
immediate watcher on activeStep fires loadExtractionSession()
synchronously on mount, racing ahead of the default layout's async
tenant fetch — so the request went out with no X-Tenant-ID header and
the API correctly rejected it with 400, surfaced to the user as
"Failed to load extraction conversation". The existing tenantVersion
watcher already retriggers the load once the tenant resolves (via the
loadWorkspaceStatus -> statusProjection.workspace_mode chain), so
adding the guard is sufficient to fix the race.
Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
📝 WalkthroughSummary by CodeRabbit
WalkthroughCWE-862 (Missing Authorization) mitigation: Estimated code review effort: 2 (Simple) | ~10 minutes Changes
Related issues: None referenced in provided diff/summary. Related PRs: None referenced in provided diff/summary. Suggested labels: security, authorization-fix, tenant-isolation Suggested reviewers: Assign someone with authority over tenant-context lifecycle in the Vue frontend and someone who owns test conventions for this repo. Notes:
🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
Problem
On a hard refresh of
/knowledge-graphs/{id}/manage?step=graph-management,the Graph Management Assistant fails to load with:
Root cause
loadExtractionSession()inmanage.vuewas the only data loader on thispage missing the
hasTenant.valueguard that every sibling loader alreadyhas (
loadKgIdentity,loadWorkspaceStatus,loadOverviewMetrics,loadArchivedWriteCount,loadGraphManagementDataSources,refreshDesignArtifacts).The page has an
immediate: truewatcher onactiveStepthat callsloadExtractionSession()synchronously on mount. On a hard refresh, allNuxt
useStateresets, so this fires before the default layout's asyncfetchTenants()has resolved and populatedcurrentTenantId. The requestgoes out with no
X-Tenant-IDheader, and the API correctly rejects itwith 400 — surfaced to the user as a generic error toast.
On a normal client-side navigation (not a hard refresh) this race doesn't
manifest, since tenant state is already warm in memory — matching what was
observed.
Fix
Add the missing
!hasTenant.valueguard, matching the establishedconvention for every other loader on this page. The existing
tenantVersionwatcher already re-triggers the extraction session loadonce the tenant resolves (via the
loadWorkspaceStatus→statusProjection.workspace_modewatch chain), so no additional retrylogic is needed.
Testing
Added
graph-management-session-tenant-guard.test.ts(structuralsource-reading test, matching this page's existing test conventions):
hasTenant.valueconvention across the page's other loaders as a regression baselineTest plan
dev-uiunit test suite run — no new failures (pre-existing unrelated failures in 9 other files, confirmed present onmainbefore this change too)Made with Cursor