Skip to content

Handle new Komoot API variants and prevent single-tour parse failures from dropping entire batch - #26

Merged
Tsadoq merged 11 commits into
mainfrom
fix/komoot-api-compatibility
Apr 13, 2026
Merged

Handle new Komoot API variants and prevent single-tour parse failures from dropping entire batch#26
Tsadoq merged 11 commits into
mainfrom
fix/komoot-api-compatibility

Conversation

@Tsadoq

@Tsadoq Tsadoq commented Apr 13, 2026

Copy link
Copy Markdown
Owner

No description provided.

… 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.amount validation 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.

Comment thread kompy/way_type.py
Comment thread tests/test_waytype.py Outdated
Comment thread kompy/komoot_connector.py Outdated
Tsadoq and others added 3 commits April 13, 2026 09:29
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.amount to be 0 or 1 (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.

Comment thread kompy/komoot_connector.py Outdated
Comment thread kompy/komoot_connector.py Outdated
Tsadoq and others added 2 commits April 13, 2026 09:33
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.amount boundary values 0 and 1, 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.

Comment thread tests/test_komoot_connector.py Outdated
Comment thread tests/test_komoot_connector.py
Comment thread kompy/komoot_connector.py
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}')
Comment thread kompy/komoot_connector.py Outdated
Tsadoq and others added 5 commits April 13, 2026 09:42
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
@Tsadoq
Tsadoq merged commit a85803b into main Apr 13, 2026
1 check passed
@Tsadoq
Tsadoq deleted the fix/komoot-api-compatibility branch April 13, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants