Skip to content

chore(lint): type JSON-parsed task data in a2a-server#27685

Open
Eswar809 wants to merge 1 commit into
google-gemini:mainfrom
Eswar809:chore/lint-unsafe-assign-a2a
Open

chore(lint): type JSON-parsed task data in a2a-server#27685
Eswar809 wants to merge 1 commit into
google-gemini:mainfrom
Eswar809:chore/lint-unsafe-assign-a2a

Conversation

@Eswar809

@Eswar809 Eswar809 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Part of the linter hygiene epic (#19440), which calls out unsafe assignments as a target. This eliminates four @typescript-eslint/no-unsafe-assignment suppressions in the a2a-server persistence/restore paths by typing the values deserialized from JSON instead of leaving them as any.

Changes

  • commands/restore.ts — annotate the parsed checkpoint as unknown; it is immediately validated by a Zod safeParse, which already accepts unknown. No new suppression.
  • persistence/gcs.ts — type the loaded task metadata as PersistedTaskMetadata (consistent with the existing as PersistedTaskMetadata usage elsewhere in the same file) and reuse the existing getContextIdFromMetadata helper to read the context id in a type-safe way.

Net result: four no-unsafe-assignment suppressions removed, one no-unsafe-type-assertion added in gcs.ts.

Behavior

Unchanged for the documented metadata shape — _contextId is always written as a string (see agent/executor.ts), and getContextIdFromMetadata returns it directly. For malformed/non-string values it now falls back to a fresh uuidv4() instead of propagating a non-string, which is slightly more robust.

Testing

  • eslint clean on both files
  • tsc --noEmit passes for @google/gemini-cli-a2a-server
  • Existing unit tests pass: gcs.test.ts (12) and restore.test.ts (6)

Eliminates four `@typescript-eslint/no-unsafe-assignment` suppressions in
the a2a-server persistence/restore paths by typing the values deserialized
from JSON instead of leaving them as `any`:

- commands/restore.ts: annotate the parsed checkpoint as `unknown`; it is
  immediately validated by a Zod `safeParse`, which accepts `unknown`.
- persistence/gcs.ts: type the loaded task metadata as `PersistedTaskMetadata`
  (consistent with the existing `as PersistedTaskMetadata` usage in the same
  file) and reuse the existing `getContextIdFromMetadata` helper to read the
  context id in a type-safe way.

Net result: four no-unsafe-assignment suppressions removed, one
no-unsafe-type-assertion added in gcs.ts. Behavior is unchanged for the
documented metadata shape (`_contextId` is always a string).

Part of google-gemini#19440
@Eswar809 Eswar809 requested a review from a team as a code owner June 5, 2026 06:02
@gemini-code-assist

Copy link
Copy Markdown
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 focuses on enhancing type safety within the a2a-server by addressing unsafe assignments during JSON deserialization. By explicitly typing parsed data and utilizing existing validation helpers, the changes reduce reliance on 'any' types and suppressions, contributing to the ongoing linter hygiene epic.

Highlights

  • Type Safety Improvements: Replaced 'any' types with 'unknown' or explicit interfaces for JSON-parsed data to improve type safety and comply with linter rules.
  • Linter Hygiene: Removed four instances of '@typescript-eslint/no-unsafe-assignment' suppressions across the persistence and restore paths.
  • Robust Metadata Handling: Integrated the 'getContextIdFromMetadata' helper to ensure type-safe access to context IDs, improving robustness for malformed metadata.
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 the 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 counterproductive. 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.

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.

@github-actions github-actions Bot added the size/s A small PR label Jun 5, 2026
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

📊 PR Size: size/S

  • Lines changed: 17
  • Additions: +9
  • Deletions: -8
  • Files changed: 2

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

Copy link
Copy Markdown
Contributor

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 improves type safety and cleans up ESLint disable comments in the a2a-server package. In restore.ts, parsed JSON is now typed as unknown before schema validation. In gcs.ts, explicit type assertions and the getContextIdFromMetadata helper are introduced to avoid unsafe assignments. There are no review comments, and I have no feedback to provide.

@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p2 Important but can be addressed in a future release. size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant