Skip to content

feat(server): add v0.3 legacy compatibility for database models#783

Open
sokoliva wants to merge 5 commits intoa2aproject:1.0-devfrom
sokoliva:database-compatibility-1-0
Open

feat(server): add v0.3 legacy compatibility for database models#783
sokoliva wants to merge 5 commits intoa2aproject:1.0-devfrom
sokoliva:database-compatibility-1-0

Conversation

@sokoliva
Copy link
Contributor

@sokoliva sokoliva commented Mar 6, 2026

Description

Implements a lazy-loading fallback mechanism to handle legacy v0.3 data stored in the database. When modern Protobuf parsing fails, it attempts to validate and convert the data using v0.3 Pydantic models and conversion utilities. This ensures backward compatibility for existing records containing string-based enums and old field structures.

Contributing Guide

  • Follow the CONTRIBUTING Guide.
  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.
    • Important Prefixes for release-please:
      • fix: which represents bug fixes, and correlates to a SemVer patch.
      • feat: represents a new feature, and correlates to a SemVer minor.
      • feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.
  • Ensure the tests and linter pass (Run bash scripts/format.sh from the repository root to format)
  • Appropriate docs were updated (if necessary)

Fixes #715 🦕

@sokoliva sokoliva requested a review from a team as a code owner March 6, 2026 16:45
@sokoliva sokoliva requested a review from ishymko March 6, 2026 16:45
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a critical backward compatibility layer for database models, allowing the server to seamlessly read and interpret data stored in the legacy v0.3 format. This ensures that existing records, which may contain older data structures like string-based enums, can be correctly processed by the updated system without requiring a full data migration. The changes primarily involve adding a fallback mechanism during data deserialization and providing the necessary conversion utilities.

Highlights

  • Legacy Data Compatibility: Implemented a lazy-loading fallback mechanism to ensure backward compatibility with v0.3 database records. When modern Protobuf parsing fails, the system now attempts to validate and convert data using v0.3 Pydantic models and dedicated conversion utilities.
  • Robust Data Retrieval: Enhanced data retrieval logic in process_result_value to gracefully handle ParseError and ValueError during Protobuf deserialization, triggering the legacy conversion process for both single items and lists of items.
  • Lazy Conversion Mapping: Introduced a _get_legacy_conversions function that lazily loads a mapping between current Protobuf types (TaskStatus, Message, Artifact) and their corresponding v0.3 Pydantic models and conversion functions, optimizing performance and preventing circular dependencies.
  • Comprehensive Test Coverage: Added a new detailed test case (test_get_0_3_task_detailed) to rigorously verify the correct conversion of complex v0.3 task data, including string-based enums and different field structures, into modern Protobuf models.
Changelog
  • src/a2a/server/models.py
    • Added imports for Callable, ParseError, ValidationError, and v0.3 compatibility modules.
    • Modified process_result_value to include a try-except block for Protobuf parsing, falling back to legacy v0.3 Pydantic model validation and conversion on failure.
    • Implemented a _get_legacy_conversions function for lazy loading of type-to-conversion mappings for TaskStatus, Message, and Artifact.
  • tests/server/tasks/test_database_task_store.py
    • Added test_get_0_3_task_detailed to verify the successful retrieval and conversion of detailed legacy v0.3 task data from the database to modern Protobuf models.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a fallback mechanism for backward compatibility with v0.3 database models. When modern Protobuf parsing fails, it attempts to deserialize data using legacy v0.3 Pydantic models and then convert them. The changes are logical and include a thorough test case to validate the new functionality. My review includes suggestions to improve type hints for increased clarity and points out potentially missing imports in the new test file.

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.

1 participant