fix(parcels): guard NULL geom + None lat/lon в isochrones/poi-score (#1201) #1251
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#1251
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/isochrones-poi-null-geom-guard"
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
Closes #1201 (P2 prod 500).
GET /{cad}/isochronesиGET /{cad}/poi-scoreотдавали 500 для участков с NULL-геометрией вcad_parcels_geom(VIEW надcad_parcelsгдеgeomnullable, ~964 prod-строк задокументировано вanalyze:1504-1507).Root cause
SQL UNION без
geom IS NOT NULLфильтра:cad_quarters_geom) ПЕРЕКРЫВАЕТ валидную из поздней —LIMIT 1берёт первую попавшуюся.ST_Centroid(NULL)→NULL→coord_row["lat"] = None→float(None)→TypeError→ 500 (вместо честного 404).Guard
if not coord_rowне ловил: RowMapping с None-полями truthy.Fix
Зеркало паттерна из
analyze(parcels.py:1418-1438) для обоих эндпоинтов:AND geom IS NOT NULLво всех 3 ветках UNION.coord_row.get("lat") is None— на случай битого polygon'а (NOT-NULL geom, NULL centroid).Test plan
pytest tests/api/v1/ -k "isochrones or poi_score or analyze"→ 26 passed.ruff check→ All checks passed.Closes #1201
`cad_parcels_geom` — VIEW над `cad_parcels` где `geom` nullable (~964 prod- строк с NULL geom задокументировано в analyze:1504-1507). Без фильтра `geom IS NOT NULL` в UNION-ветках: - NULL-строка из ранней ветки (`cad_quarters_geom`) ПЕРЕКРЫВАЕТ валидную геометрию из поздней (`cad_parcels_geom`) — LIMIT 1 берёт первую попавшуюся. - ST_Centroid(NULL) → NULL → coord_row.lat = NULL → float(None) → TypeError → 500 (вместо честного 404). Guard `if not coord_row` НЕ ловил эту дыру: RowMapping с None-полями truthy. Зеркало паттерна из analyze (parcels.py:1418-1438) для обоих эндпоинтов (`/isochrones` + `/poi-score`): 1. `AND geom IS NOT NULL` во ВСЕХ ветках UNION. 2. Belt-and-suspenders: явная проверка `coord_row.get("lat") is None` на случай топологически битого polygon'а (NOT-NULL geom, NULL centroid). 26 analyze/isochrones/poi-score юнит-тестов зелёные. ruff clean. Closes #1201