Code Monkey home page Code Monkey logo

madison-transit-api-gtfs's People

Contributors

dependabot[bot] avatar gtracy avatar

Stargazers

 avatar  avatar

Watchers

 avatar

madison-transit-api-gtfs's Issues

Deploy the API documentation

The docs still live in the old GAE/python repo. Now that the subdomain has been switched, the docs are no longer accessible.

Track API calls by dev key

The old API implementation tracked metrics for usage of the API. Need to implement that here as well.

Debug: Missing id property in the GTFS RT feed

These debug errors are rare but come in bursts. We probably can't control the missing properties from Metro, but we need to make sure we are handling the situation correction.

/v1/getarrivals?key=XXX&stopID=533

{
"level": 50,
"time": 1649559190797,
"pid": 13,
"hostname": "169.254.186.185",
"obj": null,
"property": "id",
"msg": "missing feed property"
}

Error thrown when a routeID filter is applied to getarrivals and the route is not live

The end user experience appears graceful but this error is being thrown on the requests.

{
"level": 50,
"time": 1662035462719,
"pid": 15,
"hostname": "169.254.5.97",
"err": {
"type": "TypeError",
"message": "Cannot read property 'route_id' of undefined",
"stack": "TypeError: Cannot read property 'route_id' of undefined\n at /var/task/api/fetch.js:44:40\n at Array.forEach ()\n at Object.module.exports.fetch_trips (/var/task/api/fetch.js:42:21)\n at runMicrotasks ()\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at async /var/task/api/schedule.js:33:23"
},
"msg": "Cannot read property 'route_id' of undefined"
}

Replace console logging with a more mature solution

The project started as a simple prototype and quickly blossomed into an API replacement.

I got in the bad habit of using console logging everywhere which makes monitoring and alerting way harder than it should be.

Implement a better logging framework such as logme or pino throughout the entire codebase.

Debug: missing label property if GTFS RT feed

These debug errors are rare but come in bursts. We probably can't control the missing properties from Metro, but we need to make sure we are handling the situation correction.

/v1/getarrivals?key=wisc81jw&stopID=971

{
"level": 50,
"time": 1649558980128,
"pid": 13,
"hostname": "169.254.186.185",
"obj": null,
"property": "label",
"msg": "missing feed property"
}

Build in support for dynamic service ID usage which is based on the calendar

GTFS supports the notion of different services which are activated based on the calendar. This means that the GTFS file definitions can list out multiple definitions for the same routes, stops and trips in a single GTFS file. Choosing the correct one is dependent on the date.

The current implementation is dynamic based on the date. Instead, it depends on the correct data being loaded into the production database and code.

There's an opportunity to be smarter about choosing the right service based on the calendar making it far easier to load data and not worrying about rotating the GTFS data on the exact date the changes go into effect.

GTFS parsing error : missing trip_headsign

{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "TypeError: Cannot read property 'trip_headsign' of undefined",
"reason": {
"errorType": "TypeError",
"errorMessage": "Cannot read property 'trip_headsign' of undefined",
"stack": [
"TypeError: Cannot read property 'trip_headsign' of undefined",
" at /var/task/api/schedule.js:49:43",
" at processTicksAndRejections (internal/process/task_queues.js:95:5)"
]
},
"promise": {},
"stack": [
"Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'trip_headsign' of undefined",
" at process. (/var/runtime/index.js:35:15)",
" at process.emit (events.js:400:28)",
" at process.emit (domain.js:475:12)",
" at processPromiseRejections (internal/process/promises.js:245:33)",
" at processTicksAndRejections (internal/process/task_queues.js:96:32)"
]
}

TypeError: Cannot read property 'route_short_name' of undefined

{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "TypeError: Cannot read property 'route_short_name' of undefined",
"reason": {
"errorType": "TypeError",
"errorMessage": "Cannot read property 'route_short_name' of undefined",
"stack": [
"TypeError: Cannot read property 'route_short_name' of undefined",
" at /var/task/api/schedule.js:70:77",
" at runMicrotasks ()",
" at processTicksAndRejections (internal/process/task_queues.js:95:5)"
]
},
"promise": {},
"stack": [
"Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'route_short_name' of undefined",
" at process. (/var/runtime/index.js:35:15)",
" at process.emit (events.js:400:28)",
" at process.emit (domain.js:475:12)",
" at processPromiseRejections (internal/process/promises.js:245:33)",
" at processTicksAndRejections (internal/process/task_queues.js:96:32)"
]
}

add TTL to the gtfs tables in Dynamo

items in Stops_gtfs and Trips_gtfs get rebuilt on every import which means items can become stale and invalid.

start adding a TTL property in order to leverage the built in delete function of Dynamo

Borked logging syntax. Come on, dude.

{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "TypeError: req.log_error is not a function",
"reason": {
"errorType": "TypeError",
"errorMessage": "req.log_error is not a function",
"stack": [
"TypeError: req.log_error is not a function",
" at /var/task/api/schedule.js:70:29",
" at processTicksAndRejections (internal/process/task_queues.js:95:5)"
]
},
"promise": {},
"stack": [
"Runtime.UnhandledPromiseRejection: TypeError: req.log_error is not a function",
" at process. (/var/runtime/index.js:35:15)",
" at process.emit (events.js:400:28)",
" at process.emit (domain.js:475:12)",
" at processPromiseRejections (internal/process/promises.js:245:33)",
" at processTicksAndRejections (internal/process/task_queues.js:96:32)"
]
}

The calendar import script has a time gap between the service dates

[ { service_id: '103', start_date: 2022-12-05T04:59:59.999Z, end_date: 2023-03-04T05:00:00.000Z }, { service_id: '104', start_date: 2023-03-06T04:59:59.999Z, end_date: 2023-06-10T04:00:00.000Z } ]

there is a 48 hour gap between those two because the the first service should run through the end of 03-04 and the second service should start at the beginning of 03-05.

missing vehicle details in RT feed

{
"level": 50,
"time": 1645024238157,
"pid": 22,
"hostname": "169.254.194.57",
"err": {
"type": "TypeError",
"message": "Cannot read property 'id' of null",
"stack": "TypeError: Cannot read property 'id' of null\n at Object.module.exports.getValue (/var/task/api/utils.js:67:19)\n at /var/task/api/fetch.js:54:53\n at Array.forEach ()\n at /var/task/api/fetch.js:46:54\n at Array.forEach ()\n at Object.module.exports.fetch_trips (/var/task/api/fetch.js:43:21)\n at runMicrotasks ()\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at async /var/task/api/schedule.js:33:23"
},
"msg": "Cannot read property 'id' of null"
}

Invalid request logging event

{
"level": 50,
"time": 1644291303153,
"pid": 15,
"hostname": "169.254.194.205",
"err": {
"type": "Error",
"message": "Message (user) attribute 'stopid' must contain a non-empty value of type 'String'.",
"stack": "InvalidParameterValue: Message (user) attribute 'stopid' must contain a non-empty value of type 'String'.\n at Request.extractError (/var/task/node_modules/aws-sdk/lib/protocol/query.js:50:29)\n at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20)\n at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10)\n at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:686:14)\n at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)\n at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)\n at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10\n at Request. (/var/task/node_modules/aws-sdk/lib/request.js:38:9)\n at Request. (/var/task/node_modules/aws-sdk/lib/request.js:688:12)\n at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:116:18)",
"code": "InvalidParameterValue",
"time": "2022-02-08T03:35:03.153Z",
"requestId": "857ca241-3944-5db2-b1a9-f83ade634c7f",
"statusCode": 400,
"retryable": false,
"retryDelay": 9.972165703280101
},
"msg": "queue.push() exception"
}

missing data fields in fetch_trips throws TypeError

{
"level": 50,
"time": 1643398528520,
"pid": 14,
"hostname": "169.254.50.249",
"err": {
"type": "TypeError",
"message": "Cannot read property 'id' of null",
"stack": "TypeError: Cannot read property 'id' of null\n at /var/task/api/fetch.js:53:73\n at Array.forEach ()\n at /var/task/api/fetch.js:45:54\n at Array.forEach ()\n at Object.module.exports.fetch_trips (/var/task/api/fetch.js:42:21)\n at runMicrotasks ()\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\n at async /var/task/api/schedule.js:30:23"
},
"msg": "Cannot read property 'id' of null"
}

Runtime error on missing dev key

{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "TypeError: Cannot read property 'toLowerCase' of undefined",
"reason": {
"errorType": "TypeError",
"errorMessage": "Cannot read property 'toLowerCase' of undefined",
"stack": [
"TypeError: Cannot read property 'toLowerCase' of undefined",
" at module.exports.validateDevKey (/var/task/api/devkey.js:21:39)",
" at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5)",
" at next (/var/task/node_modules/express/lib/router/route.js:137:13)",
" at module.exports.afterHours (/var/task/api/utils.js:21:9)",
" at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5)",
" at next (/var/task/node_modules/express/lib/router/route.js:137:13)",
" at Route.dispatch (/var/task/node_modules/express/lib/router/route.js:112:3)",
" at Layer.handle [as handle_request] (/var/task/node_modules/express/lib/router/layer.js:95:5)",
" at /var/task/node_modules/express/lib/router/index.js:281:22",
" at Function.process_params (/var/task/node_modules/express/lib/router/index.js:341:12)"
]
},
"promise": {},
"stack": [
"Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'toLowerCase' of undefined",
" at process. (/var/runtime/index.js:35:15)",
" at process.emit (events.js:400:28)",
" at process.emit (domain.js:475:12)",
" at processPromiseRejections (internal/process/promises.js:245:33)",
" at processTicksAndRejections (internal/process/task_queues.js:96:32)"
]
}

TypeError: Cannot read property 'bikes_allowed' of undefined

{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "TypeError: Cannot read property 'bikes_allowed' of undefined",
"reason": {
"errorType": "TypeError",
"errorMessage": "Cannot read property 'bikes_allowed' of undefined",
"stack": [
"TypeError: Cannot read property 'bikes_allowed' of undefined",
" at /var/task/api/schedule.js:84:54",
" at runMicrotasks ()",
" at processTicksAndRejections (internal/process/task_queues.js:95:5)"
]
},
"promise": {},
"stack": [
"Runtime.UnhandledPromiseRejection: TypeError: Cannot read property 'bikes_allowed' of undefined",
" at process. (/var/runtime/index.js:35:15)",
" at process.emit (events.js:400:28)",
" at process.emit (domain.js:475:12)",
" at processPromiseRejections (internal/process/promises.js:245:33)",
" at processTicksAndRejections (internal/process/task_queues.js:96:32)"
]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.