Handle new Komoot API variants and prevent single-tour parse failures from dropping entire batch - #26
Conversation
… from dropping entire batch - Add mountaineering_advanced sport type and wt#alpine_bike way type constants - Loosen WayType amount validation to accept 0.0 and 1.0 (inclusive bounds) - Replace tour list comprehension with per-tour try/except so unknown variants log a warning instead of failing the whole request
There was a problem hiding this comment.
Pull request overview
This PR updates the Komoot client to better tolerate new/variant API payloads by expanding supported constants and preventing a single malformed tour from failing an entire get_tours() batch.
Changes:
- Relax
WayType.amountvalidation to allow inclusive bounds (0 <= amount <= 1) and adjust the corresponding unit test inputs. - Make
KomootConnector.get_tours()resilient by skipping tours that fail to parse instead of raising for the whole batch. - Add newly observed Komoot API constants (
wt#alpine_bike,mountaineering_advanced) to supported lists.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
kompy/komoot_connector.py |
Skips individual tour parse failures while continuing to return the rest of the batch. |
kompy/way_type.py |
Changes amount validation to be inclusive (0..1). |
tests/test_waytype.py |
Updates invalid-amount test cases to reflect inclusive bounds. |
kompy/constants/way_type.py |
Adds ALPINE_BIKE way type constant. |
kompy/constants/activities.py |
Adds MOUNTAINEERING_ADVANCED activity constant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates kompy to be more tolerant of Komoot API schema variations by expanding supported constants, relaxing WayType boundary validation, and ensuring a single malformed tour payload doesn’t fail an entire get_tours() batch.
Changes:
- Allow
WayType.amountto be0or1(inclusive bounds) and update tests accordingly. - Add newly observed Komoot API variants to supported constants (
wt#alpine_bike,mountaineering_advanced). - Change
KomootConnector.get_tours()to skip tours that fail parsing instead of failing the full call.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_waytype.py |
Updates tests to validate inclusive boundary amounts for WayType. |
kompy/way_type.py |
Relaxes validation to allow amount in [0, 1] and updates error text/docs. |
kompy/komoot_connector.py |
Makes get_tours() resilient by skipping unparsable tour entries. |
kompy/constants/way_type.py |
Adds new Komoot way type variant wt#alpine_bike. |
kompy/constants/activities.py |
Adds new Komoot sport type mountaineering_advanced. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Improves robustness when consuming Komoot tour lists by tolerating per-item parsing failures, and extends supported Komoot constants/validation to match newer API variants.
Changes:
- Allow
WayType.amountboundary values0and1, and update unit tests accordingly. - Update
KomootConnector.get_tours()to skip malformed tour entries instead of failing the whole batch; add a regression test. - Extend supported constants for Komoot way types and activities (
ALPINE_BIKE,MOUNTAINEERING_ADVANCED).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_waytype.py | Expands coverage to include valid boundary amounts (0 and 1). |
| tests/test_komoot_connector.py | Adds a regression test ensuring malformed tours don’t drop the full result set. |
| kompy/way_type.py | Updates WayType validation and error message to accept inclusive bounds. |
| kompy/komoot_connector.py | Implements per-tour exception handling during list parsing. |
| kompy/constants/way_type.py | Adds ALPINE_BIKE way type constant. |
| kompy/constants/activities.py | Adds MOUNTAINEERING_ADVANCED activity constant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| tour_objects.append(Tour(tour_dict)) | ||
| except (KeyError, TypeError, ValueError) as e: | ||
| tour_id = tour_dict.get('id', 'unknown') if isinstance(tour_dict, dict) else 'unknown' | ||
| logger.exception(f'Failed to parse tour {tour_id}: {e}') |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…exity - Update fit_tool from 0.9.13 (unavailable) to 0.9.14 - Extract sport_types validation into _validate_sport_types to bring get_tours cyclomatic complexity from 26 to under the flake8 limit of 25
No description provided.