🐛 Bugfix: Auto-clean account when exists in Supabase but not in postgresql#3002
Open
xuyaqist wants to merge 6 commits into
Open
🐛 Bugfix: Auto-clean account when exists in Supabase but not in postgresql#3002xuyaqist wants to merge 6 commits into
xuyaqist wants to merge 6 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR attempts to address inconsistent user state between Supabase and the local PostgreSQL DB by deleting “orphaned” Supabase accounts when the corresponding local tenant relationship is missing. It also changes the A2A response payload shape for message/task parts and adjusts image sizing in the agent-development documentation.
Changes:
- Add Supabase admin-client deletion logic in
get_user_infowhenuser_tenantis missing. - Modify A2A adapter/server responses to omit
type: "text"in generatedpartsobjects (and in one place omitmediaTypetoo). - Increase documentation screenshot image widths from 50% to 80% (EN/ZH).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| doc/docs/zh/user-guide/agent-development.md | Increases embedded image width for A2A discovery screenshots. |
| doc/docs/en/user-guide/agent-development.md | Same image width adjustment for English docs. |
| backend/services/user_management_service.py | Deletes Supabase users when local tenant relationship is missing during user info lookup. |
| backend/services/a2a_server_service.py | Changes emitted A2A parts objects (drops type, and in one path drops mediaType). |
| backend/services/a2a_agent_adapter.py | Changes default/converted A2A parts shape (drops type, sometimes mediaType), impacting existing contract/tests. |
Comments suppressed due to low confidence (4)
backend/services/a2a_agent_adapter.py:272
build_a2a_message_responsenow creates default text parts without atypefield. Repository tests and existing payloads consistently includetype: "text"for parts; dropping it will cause incompatibilities unless every consumer is updated. Consider restoringtype(and keepingmediaType) for generated text parts.
if parts:
message_parts = parts
elif text:
message_parts = [{"text": text, "mediaType": _MEDIA_TYPE_TEXT}]
else:
message_parts = [{"text": "", "mediaType": _MEDIA_TYPE_TEXT}]
backend/services/a2a_agent_adapter.py:298
_content_to_artifact_partsreturns parts withouttype, while other parts in the codebase/tests expecttype: "text"(and oftenmediaType). To keep A2A artifact parts consistent and avoid downstream parsing issues, includetypefor generated text parts (and preservemediaType).
"""Convert content/parts into artifact parts format."""
if parts:
return parts
if isinstance(content, dict):
if content.get("type") == "text":
return [{"text": content.get("text", ""), "mediaType": _MEDIA_TYPE_TEXT}]
return [{"text": str(content), "mediaType": _MEDIA_TYPE_TEXT}]
backend/services/a2a_agent_adapter.py:347
_message_to_parts_formatnow emitsparts: [{"text": ...}]withouttype(and withoutmediaType). This will fail existing unit tests (they assertparts[0]["type"] == "text") and makes status messages inconsistent with other A2A responses. Please includetype: "text"(and ideallymediaType: "text/plain") when synthesizing parts here.
text = str(message)
return {
"role": role,
"parts": [{"text": text}]
}
backend/services/a2a_server_service.py:884
get_tasknow returns artifact parts as[{"text": ...}](notypeand nomediaType), while other responses in this module/adapter typically include at leastmediaType: "text/plain"(and historicallytype). This inconsistency can break clients that rely on uniform Part objects. Consider includingmediaType(andtypeif required) for artifact parts.
if message:
task_obj["artifacts"] = [{
"parts": [{"text": str(message)}],
"lastChunk": True
}]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+415
to
+430
| # User exists in Supabase but not in local database - this is an inconsistent state | ||
| # Delete the orphaned Supabase account and return None to trigger 401 | ||
| logging.warning( | ||
| f"User {user_id} not found in local database, deleting orphaned Supabase account" | ||
| ) | ||
| try: | ||
| admin_client = get_supabase_admin_client() | ||
| if admin_client and hasattr(admin_client.auth, "admin"): | ||
| admin_client.auth.admin.delete_user(user_id) | ||
| logging.info(f"Deleted orphaned Supabase user {user_id}") | ||
| else: | ||
| logging.warning(f"Could not get Supabase admin client to delete user {user_id}") | ||
| except Exception as delete_err: | ||
| logging.error( | ||
| f"Failed to delete orphaned Supabase user {user_id}: {str(delete_err)}" | ||
| ) |
688c34a to
8c1dcf3
Compare
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.
No description provided.