fix(recommend): cad_buildings.floors is INTEGER not TEXT (HOTFIX) #218
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#218
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/recommend-mix-floors-integer"
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?
🔴 Hotfix — PROD 500
Endpoint
/api/v1/analytics/recommend/mixпадает на любом районе ЕКБ:Root cause
_district_cadastre_baseline(analytics_queries.py:1354) использует regex~противcb.floors. Comment утверждает чтоfloors— TEXT, но реальный schema:Regex op
~не работает с integer → SQL crash → 500 response.Fix
Удаляем regex defensive check (предназначался для значений вроде
'1-2','2-3'), заменяем на прямое сравнениеcb.floors >= 3. NULL safety сохраняется черезOR cb.purpose ILIKE '%многокв%'.Verify
EXPLAIN на проде после fix:
Test plan
/api/v1/analytics/recommend/mixbody{"district_name":"Кировский","target_class":"Comfort",...}→ HTTP 200 с JSONPhantom column gate (PR #216)
Этот bug — именно тот класс ошибок что #197/#216 призван ловить, но
_district_cadastre_baselineSQL не покрыт integration тестами (нет вtest_phantom_columns.py). Должен быть добавлен в follow-up (тест регрессии) — отдельный issue.Closes (no issue — direct prod report by user)
PROD 500 on /api/v1/analytics/recommend/mix: psycopg.errors.UndefinedFunction: operator does not exist: integer ~ unknown LINE 19: AND ((cb.floors ~ '^[0-9]+$' AND cb.f... _district_cadastre_baseline use regex \ on cb.floors. Schema is INTEGER (verified information_schema), so the regex defence against text values ('1-2', '2-3' etc) is misplaced — simplify to floors >= 3 with NULL safety via OR purpose ILIKE '%многокв%' fallback.Verdict: APPROVE (hotfix, ship it)
Summary
1-line hotfix для prod 500 на
/api/v1/analytics/recommend/mix. Заменён неработающий regex (cb.floors ~ '^[0-9]+$' AND cb.floors::int >= 3) на прямое сравнениеcb.floors >= 3. Корректно —floorsв текущей schema этоinteger NULL(verified viaget_object_detailsна prod), а regex-оператор~для INTEGER не определён → 500.Schema reality check
Migration #169 уже привела колонку к INT (см.
parcels.py:658docstring иtest_prod_smoke.py:65). Так что defensive regex был мёртвый код, который начал throw'ить после того как Postgres стал планировать этот путь.Correctness analysis
cb.floors >= 3для NULL rows → NULL → falsy в WHERE → строка отбрасывается. ✅OR cb.purpose ILIKE '%многокв%'— rescue branch для NULL floors с известным purpose. ✅ NULL safety сохранена.'1-2'в схеме INTEGER никогда не было — regex был theoretical guard для воображаемой схемы.Codebase scan
git grep "floors ~"→ 0 matches (✅ единственное место)git grep "floors::int"→ 0 matches (✅ единственное место)cb.floorsвстречается только в этой fixed строке (analytics_queries.py:1354)Nit / nice-to-have (non-blocking)
PR body упоминает путь
backend/app/services/site_finder/analytics_queries.py, но реальный diff правитbackend/app/services/analytics_queries.py(безsite_finder/). Просто косметика в описании.Follow-up (HIGH priority, отдельным PR)
Phantom-column gate (PR #216) НЕ покрывает
_district_cadastre_baseline— verified, вbackend/tests/integration/test_phantom_columns.pyнет упоминания floors/recommend/mix/cadastre_baseline. Этот баг проскочил все pre-merge проверки и долетел до prod. Рекомендую добавитьEXPLAIN-тест на SQL из_district_cadastre_baseline()(и заодно на все аналитические queries без покрытия) — это поймало бы текущий баг + любые будущие type-mismatch / phantom-column regression.Blocked for auto-merge
Blocked for auto-merge per scope policy (touches
backend/app/services/**). Human merge required.@lekss361 — verdict APPROVE, prod-hotfix корректен. Прошу:
_district_cadastre_baselineв phantom-column gate.