fix(sf-fe): decode cad in Server Component (B5 400 regression after #356) #359
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#359
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/cad-decode-server-component"
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
P0 hotfix — user reports
API error 400: Неверный формат кадастрового номерана/site-finder/analysis/[cad].Root cause
PR #351 первоначально decoded
params.cadв Client Component. A7 split (PR #356) refactored на Server Component +AnalysisPageContent.tsxи забыл carry decode. URL/site-finder/analysis/66%3A41%3A0204016%3A10сейчас:params.cad="66%3A41%3A0204016%3A10"(URL-encoded)encodeURIComponent(cad)→66%253A41%253A0204016%253A10(double-encoded)66%3A41%3A0204016%3A10NN:NN:NNNNNN(?::NN)?rejects → 400Fix
decodeURIComponent(cadRaw)в обоихgenerateMetadataи page export[cad]/page.tsx. Downstream видит canonical66:41:0204016:10и encode'ит ровно один раз при build URL.Verify
/site-finder/analysis/66:41:0204016:10→ POST/analyze→ 200, Section 1 render'ит данные66:41:0204016:10, не66%3A...Closes hot 400 regression.
Backend /api/v1/parcels/{cad}/analyze rejects URL-encoded cad with HTTP 400. PR #351 originally fixed by decoding params.cad in the Client Component. A7 split (PR #356) refactored into Server Component + AnalysisPageContent and forgot to carry the decode forward — every analysis page request through cad URL bar (e.g. /site-finder/analysis/66%3A41%3A0204016%3A10) now passes the encoded form to the hooks, which encodeURIComponent again, producing %253A, which FastAPI decodes once to %3A, which the regex rejects. Fix: decodeURIComponent(cadRaw) at the Server Component boundary (page.tsx) in both generateMetadata and the page export. Downstream sees canonical '66:41:0204016:10' and re-encodes exactly once when building API URLs.Deep Code Review — verdict
Summary
frontend/src/app/site-finder/analysis/[cad]/page.tsx)Verification
Decode in both Server Component boundaries — confirmed:
generateMetadata({params})—const cad = decodeURIComponent(cadRaw);then used in title/description (line ~22)AnalysisPage({params})default export — same decode at top, passed to<AnalysisPageContent cad={cad}/>downstream (line ~33)Idempotency check —
decodeURIComponent("66:41:0204016:10")returns the same string (no%XXsequences). Direct-typed canonical URL not affected; encoded URL/66%3A41%3A0204016%3A10properly decoded to canonical form. No double-decode risk.Blast radius — minimal:
AnalysisPageContent.tsxuntouched (expects decodedcadprop, contract preserved)Edge cases:
%(e.g.66%ZZ41...) →decodeURIComponentthrowsURIError. Next.js will surface as 500 page rather than 400 — acceptable, since malformed URL is user error, not regression. Not blocking; can be hardened later with try/catch if needed.Critical / High / Medium
None.
Low / nits
decodeURIComponentin try/catch to returnnotFound()onURIErrorfor hand-crafted malformed URLs.Merging immediately
P0 prod regression — proceeding to squash-merge.