-
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/geocode missing data #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request fixes handling of missing or empty data in the geocoding functionality and refactors GeoJSON API tests.
Changes:
- Improved null/undefined handling in geocoding for postcodes, areas, and addresses by coalescing values to empty strings before processing
- Enhanced error messages to be more specific (e.g., "Missing postcode column" instead of "Missing area column")
- Refactored GeoJSON API tests from using
fetchto directly calling the route handler function - Updated test expectations to include UKR18 region codes that are now being enriched during geocoding
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/server/mapping/geocode.ts | Added null/undefined handling and validation for empty values in geocoding functions, improved error messages |
| tests/feature/geojsonAPI.test.ts | Refactored tests to call GET route handler directly instead of using fetch, added createNextRequest helper function |
| tests/feature/importDataSource.test.ts | Updated test expectations to include UKR18 region codes and additional area code E14001088 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/server/mapping/geocode.ts
Outdated
| const address = addressColumns.map((c) => dataRecordJson[c] || "").join(", "); | ||
| if (!address) { | ||
| throw new Error("Missing address in row"); | ||
| } |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation logic for empty address is flawed. When all address columns contain empty strings, joining them with ", " will produce a string like ", , " (containing only commas and spaces), which is not empty. The validation should check if all columns are empty or if the trimmed result is effectively empty after removing commas and whitespace.
Consider checking if the address contains any meaningful content after joining, or validate that at least one column has a non-empty value before constructing the address string.
| const address = addressColumns.map((c) => dataRecordJson[c] || "").join(", "); | |
| if (!address) { | |
| throw new Error("Missing address in row"); | |
| } | |
| const addressParts = addressColumns.map((c) => { | |
| const value = dataRecordJson[c]; | |
| if (typeof value === "string") { | |
| return value.trim(); | |
| } | |
| return String(value ?? "").trim(); | |
| }); | |
| const hasMeaningfulAddress = addressParts.some((part) => part.length > 0); | |
| if (!hasMeaningfulAddress) { | |
| throw new Error("Missing address in row"); | |
| } | |
| const address = addressParts.join(", "); |
e209755 to
f96d118
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.