52 pre-existing backend test failures on feat/flowpilot-migration #146
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
After fixing async-fixture loop scoping in the RLS isolation test module (conftest
event_loopoverride removed, pytest-asyncio bumped 0.23.0 → 0.24.0), the backend integration suite was re-run end-to-end onfeat/flowpilot-migration. The RLS suite now passes 35/35, but the default suite surfaced 52 failures + 3 errors out of 1068 tests (1016 passing; 35 deselected — the RLS suite).Confirmed not a regression from the fixture/asyncio changes:
grep -cE "different loop|Event loop is closed|got Future"against the pytest log returns 0. All failures are pre-existing application-level issues on this branch.Dominant root causes
1. Missing
account_idon INSERT — RLS write-path regressions (largest bucket)Tenant-scoped tables now enforce
account_id NOT NULL(post Phase-4 RLS), but several service/endpoint code paths still create ORM objects without passing it. Affected relations observed in the log:trees,sessions,ai_session_steps,maintenance_schedules,script_templates,session_resolution_outputs,tree_categoriesThis matches the exact pattern CLAUDE.md warns about: "Backfill migrations adding
account_id: grep ALLModelClass(sites in service code to verifyaccount_id=is passed."Tests affected (~25):
test_branch_manager.py::test_create_fork/test_switch_branch/test_get_branch_treetest_session_branches_api.py::test_create_fork/test_switch_branchtest_session_resolutions_api.py::test_edit_output_apitest_session_suggested_fixes_api.py::test_record_decision_persists_and_bumps_state_versiontest_resolution_outputs.py::test_generate_all_creates_three_outputstest_trees.py::TestTrees::test_delete_tree_cleans_up_folder_and_tag_assignmentstest_script_builder.py::TestScriptBuilderSaveToLibrary::test_save_to_library_successtest_script_builder.py::TestScriptBuilderSlugCollision::test_slug_collision_appends_suffixtest_script_builder.py::TestScriptTemplateFilters::test_mine_filter/test_shared_filtertest_pdf_export.py::TestPDFExport::test_export_pdf_returns_pdf_content/test_export_pdf_with_no_supporting_datatest_tenant_isolation_p0.py— most failures in this filetest_maintenance_schedules.py::test_get_schedule_for_tree(ERROR)test_sessions.py::TestSessions::test_complete_session_with_cancelled_outcome(ERROR)test_tenant_isolation_p0.py::test_analytics_flow_cannot_read_other_account_tree(ERROR)2. Auth / status-code drift (≈15)
Endpoints returning
401where tests expect200/422/404, or404where tests expect403. Route or permission wiring probably changed:test_survey.py— all 8 tests (401 instead of 200/404/409/422; CSV export also drifted)test_admin.py::TestAdminEndpoints::test_change_account_role_invalidtest_uploads.py::test_delete_upload_forbidden_for_non_ownertest_session_sharing.py— 6 tests (public-share access, revoke, multiple shares, view-count, ownership guard)test_ai_endpoints.py::test_quota_returns_disabled_when_no_key/test_start_returns_503_when_disabled(AI disabled-state tests)3. PSA write-back / connection schema (4)
psa_connections.display_nameis now NOT NULL but fixtures don't set it.test_psa_writeback_phase4.py::test_resolve_posts_to_psa_and_verifies_statustest_psa_writeback_phase4.py::test_resolve_surfaces_status_verification_failuretest_psa_writeback_phase4.py::test_resolve_skips_status_transition_when_unconfiguredtest_psa_writeback_phase4.py::test_escalate_posts_internal_note_to_psa4. Migration / visibility defaulting (1)
test_tree_sharing.py::test_migration_defaults_visibility_to_teamFull failure list
All 52 FAILED + 3 ERROR test names
Suggested approach
Tackle the buckets in order — bucket 1 is the biggest lever and most mechanical:
ModelClass(sites against the tables in bucket 1 and addaccount_id=where missing. CLAUDE.md already calls this out as the failure mode.display_nameNOT NULL column.test_ai_endpoints.pydisabled-state tests against current AI feature-flag wiring.Reproduction
Run on:
feat/flowpilot-migrationat24972e8(2026-04-24). Full log retained locally at/tmp/pytest-default.logon devserver01.Closing — all 52 failures resolved on main.
Verified 2026-05-01 by running every module called out in this issue (
test_tenant_isolation_p0,test_survey,test_psa_writeback_phase4,test_branch_manager,test_session_branches_api,test_session_resolutions_api,test_session_sharing,test_session_suggested_fixes_api,test_resolution_outputs,test_script_builder,test_pdf_export,test_trees,test_uploads,test_admin,test_ai_endpoints,test_tree_sharing,test_maintenance_schedules,test_sessions) — 240/240 passed.Key fixes that landed:
0d9babb—account_idon AISessionStep creationsb18072e—account_idon PsaMemberMappingd6218f2— import all models in conftest socreate_allsees the full schema64f004a,f9248ae,c6da4eb,893b8a5, etc.)feat/flowpilot-migrationwas merged into main.