Skip to content

feat: gbfs validator - #284

Draft
Alessandro100 wants to merge 14 commits into
mainfrom
spike/gbfs-visualization
Draft

Alessandro100 wants to merge 14 commits into
mainfrom
spike/gbfs-visualization

Conversation

@Alessandro100

@Alessandro100 Alessandro100 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Adds the updated version of the gbfs validator to the mobilitydatabase (currently behind a feature flag)

Expected behavior:

Users will be able to validate their gbfs feeds on the mobilitydatabase while gaining key insights about their data

Testing tips:

  1. Find a GBFS autodiscovery URL either on the mobilitydatabase or in the systems.csv
  2. Play around with the validator (/gbfs-validator)

Notes

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with yarn test to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)
Screenshot 2026-12-02 at 13 07 24 Screenshot 2026-12-02 at 13 07 40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical proxy flaws allow access to internal services, while authentication handling can leak credentials and retain protected responses after credentials change.

17 open issues
What changed in this PR

Updates the Mobility Database’s GBFS validator with feed visualization and richer validation diagnostics.

Changes:

  • Adds normalized feed parsing, authenticated proxy fetching, and interactive maps.
  • Introduces clearer error details, shareable links, and a redesigned validation form.
  • Adds helper tests, map translations, and UI guidance.

Applied the Vercel React performance and feature-flag skills.

File Description
src/​app/​store/​saga/​gbfs-validator-saga.ts Improves validator error formatting.
src/​app/​services/​gbfs/​gbfs-feed-types.ts Defines normalized feed types.
src/​app/​services/​gbfs/​gbfs-feed-parser.ts Normalizes GBFS feed versions.
src/​app/​services/​gbfs/​gbfs-feed-parser.spec.ts Tests system-information parsing.
src/​app/​screens/​GbfsValidator/​validatorFailure.ts Explains validation failures.
src/​app/​screens/​GbfsValidator/​validatorFailure.spec.ts Tests failure explanations.
src/​app/​screens/​GbfsValidator/​validationSummary.ts Computes report summaries.
src/​app/​screens/​GbfsValidator/​validationSummary.spec.ts Tests summary calculations.
src/​app/​screens/​GbfsValidator/​ValidationReportSkeletonLoading.tsx Removes the old loading skeleton.
src/​app/​screens/​GbfsValidator/​ValidationErrorAlert.tsx Displays clearer failure guidance.
src/​app/​screens/​GbfsValidator/​recordLabel.ts Labels affected records.
src/​app/​screens/​GbfsValidator/​recordLabel.spec.ts Tests record labels.
src/​app/​screens/​GbfsValidator/​occurrenceBatch.ts Batches error occurrences.
src/​app/​screens/​GbfsValidator/​occurrenceBatch.spec.ts Tests occurrence batching.
src/​app/​screens/​GbfsValidator/​mapErrorOverlay.ts Maps errors to geographic locations.
src/​app/​screens/​GbfsValidator/​index.tsx Switches landing and report views.
src/​app/​screens/​GbfsValidator/​hooks/​useGbfsFetchJson.ts Adds proxy-aware JSON fetching.
src/​app/​screens/​GbfsValidator/​hooks/​useGbfsFeedData.ts Loads and caches parsed feeds.
src/​app/​screens/​GbfsValidator/​GbfsValidatorLanding.tsx Adds the redesigned landing screen.
src/​app/​screens/​GbfsValidator/​GbfsValidateForm.tsx Adds URL, credentials, and sample inputs.
src/​app/​screens/​GbfsValidator/​GbfsFeedSearchInput.tsx Removes the previous input form.
src/​app/​screens/​GbfsValidator/​ExpandedMapView.tsx Adds full-page map interaction.
src/​app/​screens/​GbfsValidator/​expandedMapNav.ts Tracks report-to-map navigation.
src/​app/​screens/​GbfsValidator/​errorLink.ts Encodes and resolves error links.
src/​app/​screens/​GbfsValidator/​errorLink.spec.ts Tests error-link handling.
src/​app/​screens/​GbfsValidator/​errorLabel.ts Formats readable error labels.
src/​app/​screens/​GbfsValidator/​errorLabel.spec.ts Tests error labels.
src/​app/​screens/​GbfsValidator/​errorGrouping.ts Deduplicates files and groups errors.
src/​app/​screens/​GbfsValidator/​errorGrouping.spec.ts Tests grouping and deduplication.
src/​app/​screens/​GbfsValidator/​components/​ShareReportDialog.tsx Adds report-link sharing.
src/​app/​screens/​GbfsValidator/​components/​errorDetails/​useFileJson.ts Fetches and caches source JSON.
src/​app/​screens/​GbfsValidator/​components/​errorDetails/​useErrorView.ts Prepares error-focused code views.
src/​app/​screens/​GbfsValidator/​components/​errorDetails/​specLink.ts Links version-specific specifications.
src/​app/​screens/​GbfsValidator/​components/​errorDetails/​specLink.spec.ts Tests specification links.
src/​app/​screens/​GbfsValidator/​components/​errorDetails/​schemaEnum.ts Extracts and suggests allowed values.
src/​app/​screens/​GbfsValidator/​components/​errorDetails/​schemaEnum.spec.ts Tests schema-value guidance.
src/​app/​screens/​GbfsValidator/​components/​errorDetails/​jsonLines.spec.ts Tests JSON highlighting and drift detection.
src/​app/​screens/​GbfsValidator/​components/​errorDetails/​CodeView.tsx Renders highlighted JSON snippets.
src/​app/​screens/​GbfsValidator/​components/​errorDetails/​CodeStatus.tsx Adds code-loading states and copying.
src/​app/​screens/​GbfsValidator/​components/​errorDetails/​AllowedValues.tsx Displays allowed-value suggestions.
src/​app/​screens/​GbfsValidator/​components/​errorDetails/​AllowedValues.spec.tsx Tests allowed-value rendering.
src/​app/​components/​GbfsVisualizationMap.clustering.ts Builds map features and bounds.
src/​app/​components/​GbfsMap/​vehicleTypeLabel.ts Generates readable vehicle labels.
src/​app/​components/​GbfsMap/​vehicleTypeLabel.spec.ts Tests vehicle labels.
src/​app/​components/​GbfsMap/​types.ts Defines shared popup types.
src/​app/​components/​GbfsMap/​popupFacts.ts Prepares popup facts and errors.
src/​app/​components/​GbfsMap/​popupFacts.spec.ts Tests popup data formatting.
src/​app/​components/​GbfsMap/​GbfsMapLegend.tsx Adds a collapsible map legend.
src/​app/​components/​GbfsMap/​GbfsMapFilterPanel.tsx Adds map-layer filters.
src/​app/​components/​GbfsMap/​errorBadges.ts Associates markers with error counts.
src/​app/​components/​GbfsMap/​errorBadges.spec.ts Tests error badges.
src/​app/​components/​CoveredAreaMap.tsx Integrates live GBFS visualization.
src/​app/​api/​gbfs-proxy/​route.ts Adds server-side feed proxying.
src/​app/​[locale]/​gbfs-validator/​page.tsx Uses layout-provided authentication context.
src/​app/​[locale]/​gbfs-validator/​map/​page.tsx Adds the expanded-map route.
src/​app/​[locale]/​gbfs-validator/​layout.tsx Shares credentials across validator routes.
messages/​fr.json Adds French map messages.
messages/​en.json Adds English map messages.
CLAUDE.md Documents UI design conventions.

Review effort: Balanced

Comment thread src/app/api/gbfs-proxy/route.ts Resolved
Comment thread src/app/api/gbfs-proxy/route.ts Resolved
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
mobilitydatabase-web Ready Ready Preview Dec 3, 2026 7:01pm UTC

Request Review

Alessandro100 and others added 5 commits December 3, 2026 09:49
Check every resolved address against private and reserved IPv4/IPv6 ranges inside the connection's own DNS lookup (undici agent), so redirects and DNS rebinding cannot reach internal hosts. Follow redirects manually, sending credentials only to the same origin, and refuse redirects on the OAuth token request. Refuse feeds over 50 MB and token responses over 1 MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read GBFS 3.0 num_vehicles_available, treat legacy 0/1 flags as booleans, fall back to ride_allowed for 2.2 geofencing rules, and stop stringifying objects. Resolve station_status errors by station_id, count error badges per record instead of per coordinate, skip non-finite or out-of-range coordinates, keep a close button on the expanded map in loading, error and empty states, and count an error repeated across language copies once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Key in-memory caches by a per-credentials scope, never persist authenticated files to localStorage, and expire in-memory file entries. Only the latest feed load may commit data or loading state, a new URL clears the previous feed, and choosing a sample feed clears credentials.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add an issue parameter (keyword plus a short hash of the message) so links open the right error when several share a path. Links without it still resolve by path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restore CoveredAreaMap from main so feed detail pages do not show the new GBFS visualization, and drop its now unused translation keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

*Lighthouse ran on https://mobilitydatabase-9hb751vl5-mobility-data.vercel.app/ * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 61 🟢 90 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-9hb751vl5-mobility-data.vercel.app/feeds * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 88 🟠 87 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-9hb751vl5-mobility-data.vercel.app/feeds/gtfs/mdb-2126 * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🔴 45 🟢 95 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-9hb751vl5-mobility-data.vercel.app/feeds/gtfs_rt/mdb-2585 * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟢 98 🟠 84 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-9hb751vl5-mobility-data.vercel.app/feeds/gbfs/gbfs-flamingo_porirua * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 77 🟢 94 🟢 96 🟢 100

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved defects can misreport file validity, attach errors to the wrong language’s records, and crash maps when feed data is malformed.

7 open issues
17 resolved since last review

Review effort: Balanced

Comment thread src/app/api/gbfs-proxy/route.ts Resolved
Alessandro100 and others added 2 commits December 3, 2026 13:49
A JSON body of null, an array or a scalar parsed, then crashed the
destructuring with an unhandled 500. It now gets a 400.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Errors point at record indices in their own language copy of a file,
but the map always loaded the feed's first language, so an error could
be drawn on another station. The map now loads the report's language,
the overlay keeps only that language's errors, and the expanded map
resolves linked errors in it.

Also from review:
- count a file as valid from its own errors, before language repeats
  are merged
- fall back to 'other' for inherited form factor names
- drop geofencing zones without a polygon geometry
- stop formatting the whole file when opening an error's details

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Outstanding defects include unbounded caches, credential-insensitive report reuse, cancelled map flights, unclosed upstream bodies, and visualization crashes on malformed feed data.

1 open issue
5 previously missed issues

In code that hasn't changed since last review

Medium severity Cancel upstream response bodies on error

src/​app/​api/​gbfs-proxy/​route.ts:75

Failed upstream responses leave their Undici bodies unread and uncancelled, keeping streams and connections occupied until the timeout. Cancel the body before returning this error; also cancel tokenResp.body before throwing on the OAuth failure path at line 156.

Medium severity Filter malformed vehicle type entries before building station facts

src/​app/​components/​GbfsMap/​popupFacts.ts:95

Checking only that the parsed value is an array does not make its entries safe. parseStationStatuses preserves malformed vehicle_types_available entries, so a feed containing [null] reaches the map popup and throws when labels access t.vehicle_type_id outside the try/catch. Validate or filter the entries before building the station facts.

Medium severity Skip malformed polygon coordinates when calculating bounds

src/​app/​components/​GbfsVisualizationMap.clustering.ts:170

The parser accepts polygons based only on their geometry type, so an invalid geofencing zone with coordinates: null reaches this code. It throws on flat(), even when valid station data exists, breaking the map's bounds calculation. Skip malformed coordinate arrays and non-finite positions instead of letting one invalid zone break visualization.

Medium severity Include credentials when reusing validation results

src/​app/​screens/​GbfsValidator/​ExpandedMapView.tsx:88

Reusing validation by URL alone ignores the credentials used for that result. After leaving the validator and reopening its map, the layout's auth context can be empty while Redux still holds an authenticated result for the same URL. The map then displays that old report instead of validating with the current credentials. Compare auth as well, as ValidationState does, and rerun the effect when auth changes.

Medium severity Bound the cache and prune expired entries on insertion

src/​app/​screens/​GbfsValidator/​hooks/​useGbfsFeedData.ts:28

The TTL only removes an entry when that exact URL, credential scope and language is requested again, so inspecting different feeds retains their parsed data for the tab's lifetime. Bound the cache and prune expired entries on insertion to prevent large feeds accumulating in memory. The same issue affects the JSON cache in src/app/screens/GbfsValidator/components/errorDetails/useFileJson.ts:22.

7 resolved since last review

Review effort: Balanced

Comment on lines +137 to +146
flownRef.current = true;
const id = window.setTimeout(() => {
handleRef.current?.flyToError(loc.lat, loc.lon, {
keyword: error.keyword ?? '',
message: error.message ?? '',
instancePath: error.instancePath ?? '',
fileName: link.file,
fileUrl: file.url,
});
}, MAP_SETTLE_MS);

This branch was successfully deployed

1 active deployment
Preview — 2be81541 Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants