OpenRailAssociation / osrd

An open source web application for railway infrastructure design, capacity analysis, timetabling and simulation
https://osrd.fr
GNU Lesser General Public License v3.0
415 stars 40 forks source link

Add a stop for 0s crashes the application #7868

Closed flomonster closed 1 week ago

flomonster commented 1 week ago

What happened?

When a train schedule is created with a stop at 0s, the front end crashes

image

What did you expect to happen?

It should create a stop of 0s and still work.

How can we reproduce it (as minimally and precisely as possible)?

  1. Create a scenario
  2. Add a train
  3. Add a stop of 0s to the last step
  4. Create the train

Here is what the train schedule payload looks likes (could be use for import):

[
  {
    "train_name": "a",
    "labels": [],
    "rolling_stock_name": "3B81504",
    "start_time": "2024-06-27T09:00:00Z",
    "path": [
      {
        "id": "id1150",
        "deleted": false,
        "track": "6499a8c0-6667-11e3-81ff-01f464e0362d",
        "offset": 1584
      },
      {
        "id": "id1168",
        "deleted": false,
        "uic": 87746412,
        "secondary_code": "00"
      },
      {
        "id": "id589",
        "deleted": false,
        "track": "6499fc54-6667-11e3-81ff-01f464e0362d",
        "offset": 0
      }
    ],
    "schedule": [
      {
        "at": "id1168",
        "arrival": null,
        "stop_for": "P0D",
        "on_stop_signal": false,
        "locked": false
      }
    ],
    "margins": {
      "boundaries": [],
      "values": [
        "none"
      ]
    },
    "initial_speed": 0.0,
    "comfort": "STANDARD",
    "constraint_distribution": "MARECO",
    "speed_limit_tag": null,
    "power_restrictions": [],
    "options": {
      "use_electrical_profiles": true
    }
  }
]

What operating system, browser and environment are you using?

OSRD version (top right corner Account button > Informations)

d9655c0f05166faff80f744efe979a921347777f

SharglutDev commented 1 week ago

Why is the back returning "P0D" for stop_for when we send it "PT0S" ? In front, we are testing that stop_for looks like "PTxxx" (PT0S, PT5M30S, PT6H...) like all examples in doc :

Capture d’écran 2024-06-28 à 08 54 45

flomonster commented 1 week ago

P0D is a valid duration. The front end should use a library to handle the deserialization of duration.

SharglutDev commented 1 week ago

dayjs, which is already installed on osrd, can do that so I will use it.