Skip to content

Fix critical admin deletion and valuation regressions#12

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-9657
Draft

Fix critical admin deletion and valuation regressions#12
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-9657

Conversation

@cursor

@cursor cursor Bot commented Jun 27, 2026

Copy link
Copy Markdown

Bug and impact

  • Admin user deletion could cascade through executions -> reports -> report_views, deleting shared analysis reports and other users' view history when deleting a content creator. The system account was also deletable, risking loss of cron/sync-generated platform reports.
  • ETF/index detection treated equity names containing generic words like Trust or Fund as ETF/index instruments, causing REITs and similar equities to skip stock DCF/comps valuation and silently show the wrong valuation methodology.
  • Valuation structured output capped valuation_key_assumptions at 5 even though the deterministic tool can emit more, causing structured valuation metadata to be dropped on validation failure.

Root cause

  • admin_service.delete_user deleted User rows directly without preserving owned executions/reports or protecting platform/admin accounts.
  • _is_index_or_etf used broad substring matching across names and metadata instead of respecting explicit instrument types.
  • The Pydantic output schema was stricter than the tool output and prompt contract.

Fix

  • Reassign deleted users' owned executions to the system account before deleting the personal account, and reject deletion of admin/system accounts.
  • Narrow ETF/index detection to explicit instrument types first, treat explicit equities as equities, and remove generic name-only Trust/Fund matches.
  • Allow the structured valuation output to carry the tool's full assumption list.
  • Update the admin deletion dialog copy so it no longer claims analysis runs are deleted.

Validation

  • python3 -m unittest backend.tests.test_admin_service backend.tests.test_valuation_summary
Open in Web View Automation 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant