Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unter "First Activity" gelisteter Track führ zur falschen ID? #30

Closed
Natenom opened this issue Nov 26, 2023 · 1 comment
Closed

Unter "First Activity" gelisteter Track führ zur falschen ID? #30

Natenom opened this issue Nov 26, 2023 · 1 comment
Labels
type: bug Something isn't working
Milestone

Comments

@Natenom
Copy link

Natenom commented Nov 26, 2023

Bei jedem Track, den ich über die Kachelansicht öffne ("First activity"), gibt es eine Fehlermeldung (unten) und einen HTTP Status Code 500.

Wenn die Datei z. B. "2023-06-23-090320-ELEMNT BOLT B7E4-428-0" heißt, führt der Link in der Kachelansicht zur URL "/activity/626538150891006800".

Suche ich die Datei manuell im Kalender heraus, dann werde ich auf eine andere ID geleitet und es wird alles richtig angezeigt. Das ist dann die URL, die funktioniert "/activity/626538150891006837".

2023-11-26 18:00:32 geo_activity_playground.webui.app ERROR Exception on /activity/626538150891006800 [GET]
Traceback (most recent call last):
  File "/home/me/.cache/pypoetry/virtualenvs/geo-activity-playground-SZxD7HkL-py3.11/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3790, in get_loc
    return self._engine.get_loc(casted_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "index.pyx", line 152, in pandas._libs.index.IndexEngine.get_loc
  File "index.pyx", line 181, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 2606, in pandas._libs.hashtable.Int64HashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 2630, in pandas._libs.hashtable.Int64HashTable.get_item
KeyError: 626538150891006800

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/me/.cache/pypoetry/virtualenvs/geo-activity-playground-SZxD7HkL-py3.11/lib/python3.11/site-packages/flask/app.py", line 1455, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/.cache/pypoetry/virtualenvs/geo-activity-playground-SZxD7HkL-py3.11/lib/python3.11/site-packages/flask/app.py", line 869, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/.cache/pypoetry/virtualenvs/geo-activity-playground-SZxD7HkL-py3.11/lib/python3.11/site-packages/flask/app.py", line 867, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/.cache/pypoetry/virtualenvs/geo-activity-playground-SZxD7HkL-py3.11/lib/python3.11/site-packages/flask/app.py", line 852, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/my/src/github/geo-activity-playground/geo_activity_playground/webui/app.py", line 38, in activity
    "activity.html.j2", **activity_controller.render_activity(int(id))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/my/src/github/geo-activity-playground/geo_activity_playground/webui/activity_controller.py", line 19, in render_activity
    activity = self._repository.get_activity_by_id(id)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/my/src/github/geo-activity-playground/geo_activity_playground/core/activities.py", line 49, in get_activity_by_id
    return ActivityMeta(**self.meta.loc[id])
                          ~~~~~~~~~~~~~^^^^
  File "/home/me/.cache/pypoetry/virtualenvs/geo-activity-playground-SZxD7HkL-py3.11/lib/python3.11/site-packages/pandas/core/indexing.py", line 1153, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/.cache/pypoetry/virtualenvs/geo-activity-playground-SZxD7HkL-py3.11/lib/python3.11/site-packages/pandas/core/indexing.py", line 1393, in _getitem_axis
    return self._get_label(key, axis=axis)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/.cache/pypoetry/virtualenvs/geo-activity-playground-SZxD7HkL-py3.11/lib/python3.11/site-packages/pandas/core/indexing.py", line 1343, in _get_label
    return self.obj.xs(label, axis=axis)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/.cache/pypoetry/virtualenvs/geo-activity-playground-SZxD7HkL-py3.11/lib/python3.11/site-packages/pandas/core/generic.py", line 4236, in xs
    loc = index.get_loc(key)
          ^^^^^^^^^^^^^^^^^^
  File "/home/me/.cache/pypoetry/virtualenvs/geo-activity-playground-SZxD7HkL-py3.11/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3797, in get_loc
    raise KeyError(key) from err
KeyError: 626538150891006800
2023-11-26 18:00:32 werkzeug INFO 127.0.0.1 - - [26/Nov/2023 18:00:32] "GET /activity/626538150891006800 HTTP/1.1" 500 -

@martin-ueding martin-ueding added the type: bug Something isn't working label Nov 26, 2023
@martin-ueding
Copy link
Owner

Repariert. Das Problem ist zum Ausrasten:

Ich vergebe für Aktivitäten eine ID, die aus einem Hash vom Dateipfad berechnet wird. Ich nutze einen SHA-3 mit 224 bit. Und dann nehme ich die unteren 62 bit dieser Zahl, damit es mit einem 64 bit Integer noch geht, selbst wenn der ein Vorzeichen hat. Dieser kann bis 63 bit darstellen. Soweit alles cool in Python.

JavaScript nutzt als zugrundeliegenden Datentypen für Integer einen 64-Bit Fließkommawert. Und somit wird dann aus einer Aktivitäts-ID wie 3332157568371363115 eben die Zahl 3332157568371363300, weil da eben einige Bit an Mantisse fehlen um die Zahl korrekt darzustellen. Somit hat man dann Rundungsfehler bei Integern. Das ist JavaScript.

Ich übergebe das jetzt als String an JavaScript, und damit passt es dann.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants