fix(telemetry): eliminate synthetic fallbacks in SSR fire summary and weather service #93
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
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?
Problem Statement
During the comprehensive architectural audit against
docs/ARCHITECTURE.md, two silent synthetic fallback mechanisms were uncovered in the production application:src/app/page.tsx:49-74(getSummaryData):When the upstream SiPongi API fails during Next.js server-side rendering (SSR), the
catchblock returns hardcoded fake telemetry (totalHotspots: 10334,criticalClustersCount: 48,Kalimantan Tengah: 2410,Riau: 1980). This misleads users and search engine crawlers with fabricated fire counts across Indonesia during network or API disruptions.src/lib/services/weather.ts:98-111(fetchWeatherObservation):When Open-Meteo GFS API fails and no cache exists, the service silently catches the error and returns synthetic dry-season weather (
temperatureC: 31.0,relativeHumidity: 65,windSpeedKmh: 16.0,windDirectionDeg: 120). These unmeasured synthetic wind vectors are then piped directly intosmoke-cone.tsand the composite danger scoring engine, presenting calculated smoke dispersion cones as real observations.Both mechanisms violate the non-negotiable completeness contract and silent-failure discipline:
Proposed Remediation
src/app/page.tsx:getSummaryData(), iffetchSiPongiHotspots()fails and no cached telemetry exists, return a clean empty summary (totalHotspots: 0,criticalClustersCount: 0,provincialSummaries: []).src/lib/services/weather.ts:fetchWeatherObservation(), if Open-Meteo API fails and no stale cache exists, throw a descriptive error instead of inventing synthetic wind speed and directions.src/app/api/weather/route.tsreturns HTTP 502 with structured error details when upstream is unreachable.Regression Tests:
Acceptance Criteria
src/app/page.tsxreturns 0 hotspots and empty provincial list upon SiPongi failure; no hardcoded 10,334 numbers remain anywhere in source.src/lib/services/weather.tsthrows when Open-Meteo fails without cache; no hardcoded 31°C / 16 km/h synthetic weather.pnpm exec vp checkpasses with 0 warnings.pnpm testpasses all tests.pnpm buildcompletes cleanly.