-
Notifications
You must be signed in to change notification settings - Fork 4
fix federation registration #21
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -176,13 +176,12 @@ def get_credentials(self, *, identity: Identity) -> Credentials: | |||||||||||||||
| except IdentityNotFound as e: | ||||||||||||||||
| raise VIPError(f"Credentials not found for identity {identity}") from e | ||||||||||||||||
|
|
||||||||||||||||
| def add_federation_platform(self, platform_id: str, credentials: Any) -> bool: | ||||||||||||||||
| def register_remote_platform(self, platform_id: str, credentials: Any): | ||||||||||||||||
| """ | ||||||||||||||||
| Register a remote platform for federation access | ||||||||||||||||
|
|
||||||||||||||||
| :param platform_id: ID of the remote platform | ||||||||||||||||
| :param credentials: Authentication credentials for the remote platform (public key) | ||||||||||||||||
| :return: True if registration was successful, False otherwise | ||||||||||||||||
| """ | ||||||||||||||||
| try: | ||||||||||||||||
| # Store the platform credentials | ||||||||||||||||
|
|
@@ -193,15 +192,10 @@ def add_federation_platform(self, platform_id: str, credentials: Any) -> bool: | |||||||||||||||
|
|
||||||||||||||||
| platform_identity = f"{platform_id}" | ||||||||||||||||
| public_creds = PublicCredentials(identity=f"{platform_identity}", publickey=credentials) | ||||||||||||||||
|
|
||||||||||||||||
| self._credentials_store.store_credentials(credentials=public_creds) | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| _log.info(f"Federation platform registered: {platform_id}") | ||||||||||||||||
| return True | ||||||||||||||||
| self._credentials_store.store_credentials(credentials=public_creds, overwrite=True) | ||||||||||||||||
|
||||||||||||||||
| self._credentials_store.store_credentials(credentials=public_creds, overwrite=True) | |
| try: | |
| # Prefer newer API that supports overwriting existing credentials | |
| self._credentials_store.store_credentials(credentials=public_creds, overwrite=True) | |
| except TypeError: | |
| # Fallback for older volttron-core versions that do not accept 'overwrite' | |
| self._credentials_store.store_credentials(credentials=public_creds) |
Copilot
AI
Mar 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching Exception and then logging with _log.error(...) loses the traceback context in logs; since the exception is re-raised, consider using _log.exception(...) (or exc_info=True) and avoid double-logging higher up the stack.
| except Exception as e: | |
| _log.error(f"Error registering federation platform {platform_id}: {e}") | |
| except Exception: | |
| _log.exception("Error registering federation platform %s", platform_id) |
Copilot
AI
Mar 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method previously returned bool to indicate success/failure, but now has no return type and always returns None on success while raising on error. If any callers (or an interface/abstract base) still expect a boolean result, this is a breaking API change—consider restoring -> bool with an explicit return value, or annotate -> None and ensure all callers are updated accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
platform_iddirectly as the credentialsidentitycombined withoverwrite=Truecan overwrite existing/local agent credentials if a remote platform registers with a reserved identity (e.g.,AUTH,CONTROL, etc.). Consider namespacing federation identities (e.g.,federation.<platform_id>) and/or explicitly rejecting reserved/known identities before storing, and only allowing overwrite when you have verified it's the same remote platform updating its own key.