ottojo / uulm_mensa_bot

Cafeteria order lib/cli/bot for uulm
2 stars 0 forks source link

panic: unknown mensa id #3

Open ottojo opened 1 year ago

ottojo commented 1 year ago

reproduce:

foo@bar:uulm_mensa_cli$ cargo run -- 123 menu
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failed to decode getdata response

Caused by:
    0: error decoding response body: missing field `essen` at line 18 column 9
    1: missing field `essen` at line 18 column 9', uulm_mensa_cli/src/main.rs:39:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
ottojo commented 1 year ago
 TRACE my_mensa_lib > Calling API url: https://stwulm.my-mensa.de/getdata.php?mensa_id=2&json=1&hyp=1&now=1692825857849&mode=togo&lang=de
 TRACE my_mensa_lib > Response: Response { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("stwulm.my-mensa.de")), port: None, path: "/getdata.php", query: Some("mensa_id=2&json=1&hyp=1&now=1692825857849&mode=togo&lang=de"), fragment: None }, status: 200, headers: {"server": "nginx", "date": "Wed, 23 Aug 2023 21:24:18 GMT", "content-type": "application/json; charset=utf-8", "transfer-encoding": "chunked", "connection": "keep-alive", "expires": "Thu, 19 Nov 1981 08:52:00 GMT", "cache-control": "no-store, no-cache, must-revalidate", "pragma": "no-cache", "vary": "Accept-Encoding", "set-cookie": "PHPSESSID=rn8kktf9jcffqbmrf3ji9gbake; path=/", "access-control-allow-origin": "*", "x-powered-by": "PleskLin"} }
 TRACE my_mensa_lib > Text: "{\n    \"result\": [\n        {\n            \"tag\": {\n                \"timestamp\": 1692825858,\n                \"tag_formatiert\": \"Mi <small>(23.08.)<\\/small>\",\n                \"tag_formatiert2\": \"Mi, 23.08.2023\",\n                \"tag_formatiert_rel\": \"heute\",\n                \"jahrestag\": \"234\",\n                \"wochentag\": \"Mittwoch\",\n                \"wochentag_short\": \"Mi\",\n                \"datum\": \"23.08.\",\n                \"datum2\": \"23.08.\",\n                \"datum_iso\": \"2023-08-23\",\n                \"wota_index\": \"3\",\n                \"kw\": \"34\"\n            }\n        }\n    ],\n    \"mensaname\": \"Ulm, Universität, Cafeteria Uni West\"\n}"

note: this shows only the effect of #4, but the mensatogo.php page shows an explicit error message "Einrichtung nicht gefunden" and doesnt even call getdata.php. Interesting that getdata.php seems to guess the correct mensa ID anyways...