Skip to content

🐛 Bugfix: Auto-clean account when exists in Supabase but not in postgresql#3002

Open
xuyaqist wants to merge 6 commits into
developfrom
xyq/bugfix_frontend
Open

🐛 Bugfix: Auto-clean account when exists in Supabase but not in postgresql#3002
xuyaqist wants to merge 6 commits into
developfrom
xyq/bugfix_frontend

Conversation

@xuyaqist
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 18, 2026 02:50
@xuyaqist xuyaqist requested review from Dallas98 and WMC001 as code owners May 18, 2026 02:50
@xuyaqist xuyaqist changed the title Bugfix: Auto-clean account when exists in Supabase but not in postgre Bugfix: Auto-clean account when exists in Supabase but not in postgresql May 18, 2026
@xuyaqist xuyaqist changed the title Bugfix: Auto-clean account when exists in Supabase but not in postgresql 🐛 Bugfix: Auto-clean account when exists in Supabase but not in postgresql May 18, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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_info when user_tenant is missing.
  • Modify A2A adapter/server responses to omit type: "text" in generated parts objects (and in one place omit mediaType too).
  • 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_response now creates default text parts without a type field. Repository tests and existing payloads consistently include type: "text" for parts; dropping it will cause incompatibilities unless every consumer is updated. Consider restoring type (and keeping mediaType) 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_parts returns parts without type, while other parts in the codebase/tests expect type: "text" (and often mediaType). To keep A2A artifact parts consistent and avoid downstream parsing issues, include type for generated text parts (and preserve mediaType).
        """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_format now emits parts: [{"text": ...}] without type (and without mediaType). This will fail existing unit tests (they assert parts[0]["type"] == "text") and makes status messages inconsistent with other A2A responses. Please include type: "text" (and ideally mediaType: "text/plain") when synthesizing parts here.
            text = str(message)
        return {
            "role": role,
            "parts": [{"text": text}]
        }

backend/services/a2a_server_service.py:884

  • get_task now returns artifact parts as [{"text": ...}] (no type and no mediaType), while other responses in this module/adapter typically include at least mediaType: "text/plain" (and historically type). This inconsistency can break clients that rely on uniform Part objects. Consider including mediaType (and type if 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 thread backend/services/a2a_agent_adapter.py
Comment thread backend/services/a2a_server_service.py
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)}"
)
Comment thread backend/services/a2a_server_service.py
@xuyaqist xuyaqist force-pushed the xyq/bugfix_frontend branch from 688c34a to 8c1dcf3 Compare May 18, 2026 07:47
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