fix: handle OCPI version negotiation in push_object#21
Merged
alfonsosastre merged 3 commits intofeat/push-v2-3-0-supportfrom Feb 24, 2026
Merged
fix: handle OCPI version negotiation in push_object#21alfonsosastre merged 3 commits intofeat/push-v2-3-0-supportfrom
alfonsosastre merged 3 commits intofeat/push-v2-3-0-supportfrom
Conversation
* feat: add OCPI 2.3.0 support to push functionality
send_push_request now matches endpoints by RECEIVER role for 2.3.x
(same as 2.2.x), and push_object already base64-encodes tokens for
any version beyond 2.1.x. Previously 2.3.0 pushes would silently
use an empty base_url because the version check only covered "2.2".
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor: future-proof push endpoint version check
Replace explicit startswith("2.2") or startswith("2.3") with
a negated check, so any version beyond 2.0.x/2.1.x automatically
uses RECEIVER role filtering without needing code changes.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* style: apply ruff format to push.py
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Alfonso Sastre <alfonso@elumobility.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
push_object now accepts both a versions URL and a version details URL
as endpoints_url. When a versions list is returned (data is a list),
it automatically picks the best mutual version and fetches the details
URL to discover endpoints. This follows the proper OCPI spec flow:
1. GET /versions → list of supported versions with details URLs
2. Pick best mutual version
3. GET /{version}/details → list of endpoints
4. Push to the correct module endpoint
Co-authored-by: Cursor <cursoragent@cursor.com>
The endpoint URL from version details doesn't include a trailing slash, causing the country_code to be concatenated directly (e.g. locationsDE/ELU/... instead of locations/DE/ELU/...). Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
push_objectnow handles both versions URLs and version details URLs asendpoints_urlContext
Payter's versions endpoint is at
/ocpi/ptp/versionswhich returns a list of versions. Previouslypush_objectexpected a version details URL directly, causinglist indices must be integers or slices, not strerrors.Test plan
Made with Cursor