BlinkTagInc / node-gtfs

Import GTFS transit data into SQLite and query routes, stops, times, fares and more.
MIT License
437 stars 150 forks source link

import.js throws an error because attribution_id is missing but the spec says it's optional #166

Closed Unclearogre closed 2 months ago

Unclearogre commented 3 months ago

I'm trying to get the MMM-transitfeed module working with my MagicMirror to show arrival times for the San Francisco Muni.

I'm using these endpoints:

http://api.511.org/transit/datafeeds?api_key=[your_key]&operator_id=SF
http://api.511.org/transit/tripupdates?api_key=[your_key]&agency=SF

which seem to return data but gtfs is throwing an error saying that attribution_id is required:

[2024-06-27 09:20:14.694] [ERROR] (node:2014) UnhandledPromiseRejectionWarning: Error: Missing required value in attributions.txt for attribution_id on line 2.
    at formatLine (file:///home/pi/MagicMirror/modules/MMM-transitfeed/node_modules/gtfs/lib/import.js:448:13)
    at Parser.<anonymous> (file:///home/pi/MagicMirror/modules/MMM-transitfeed/node_modules/gtfs/lib/import.js:622:28)

The spec that I found, however, seems to indicate that attribution_id is optional.

Is this a node-gtfs issue, an MMM-transitfeed problem, or something else?

Unclearogre commented 3 months ago

I found a work-around, I think. I edited the attributions.js file in node_modules/gtfs/models/gtfs to set the required flag to false. That seems to work.

brendannee commented 3 months ago

Thanks for pointing out that attribution_id is optional. I'll update the schema and publish and updated version soon.

brendannee commented 2 months ago

I just published https://github.com/BlinkTagInc/node-gtfs/releases/tag/4.13.0 which makes attribution_id optional - let me know if this works for you or if there are any other issues.