derhuerst / vbb-rest

An HTTP API for Berlin & Brandenburg public transport.
https://v6.vbb.transport.rest/
ISC License
123 stars 14 forks source link

ID must have 7 or 9 digits #38

Closed heyarne closed 4 years ago

heyarne commented 4 years ago

I'm hitting a weird error for some journeys (http below is the httpie cli).

I query for stops close to a particular location (http 'https://3.vbb.transport.rest/stops/nearby?longitude=13.471680&latitude=51.763612'):

[
  {
    "type": "stop",
    "id": "900000415725",
    "name": "Hohenbucko, Wasserturm",
    "location": {
      "type": "location",
      "id": "900415725",
      "latitude": 51.762333,
      "longitude": 13.473958
    },
    "products": {
      "suburban": false,
      "subway": false,
      "tram": false,
      "bus": true,
      "ferry": false,
      "express": false,
      "regional": false
    },
    "distance": 211
  },
  {
    "type": "stop",
    "id": "900000415722",
    "name": "Hohenbucko, Dorfmitte",
    "location": {
      "type": "location",
      "id": "900415722",
      "latitude": 51.765803,
      "longitude": 13.468745
    },
    "products": {
      "suburban": false,
      "subway": false,
      "tram": false,
      "bus": true,
      "ferry": false,
      "express": false,
      "regional": false
    },
    "distance": 317
  },
  {
    "type": "stop",
    "id": "900000415724",
    "name": "Hohenbucko, Schule",
    "location": {
      "type": "location",
      "id": "900415724",
      "latitude": 51.760778,
      "longitude": 13.46701
    },
    "products": {
      "suburban": false,
      "subway": false,
      "tram": false,
      "bus": true,
      "ferry": false,
      "express": false,
      "regional": false
    },
    "distance": 450
  },
  {
    "type": "stop",
    "id": "900000415721",
    "name": "Hohenbucko, Bhf",
    "location": {
      "type": "location",
      "id": "900415721",
      "latitude": 51.776159,
      "longitude": 13.457544
    },
    "products": {
      "suburban": false,
      "subway": false,
      "tram": false,
      "bus": true,
      "ferry": false,
      "express": false,
      "regional": false
    },
    "distance": 1701
  }
]

And similarly with other places. The ID returned on the stop has 12 digits. Now trying to request a journey I get this response (http 'https://3.vbb.transport.rest/journeys?from=900000245645&to=900000415725&arrival=1578898800'):

{
    "error": true,
    "msg": "ID must have 7 or 9 digits."
}

What does that mean? I also tried deleting some of the zeros to match the location id (see response above) but I get the same error. Where would I get the right ID? Or is something wrong with the validation code? I grepped the source code for the error message but couldn't find anything.

The stops endpoint seems to have information about the stop with the original (12-digit) id. The journey endpoint doesn't.

Something similar happened to me elsewhere. I query a nearby stop to the center of Frankfurt (Main) and get 800000002041. Trying to query for stop or journey information returns a HAFAS error: location/stop not found. Is there a mismatch between returned IDs and available stop information / journey information? Note that the above error does not complain about a stop that's not found but here it does.

derhuerst commented 4 years ago

Fixed as of https://github.com/public-transport/hafas-client@db90afe. Should be live at 3.vbb.transport.rest now.

Please reopen if you encounter this issue again.