Skip to content

fix: remove schemes nesting#220

Merged
yarolegovich merged 2 commits intospec-v1/type-updatefrom
yarolegovich/remove-spec-nesting
Feb 18, 2026
Merged

fix: remove schemes nesting#220
yarolegovich merged 2 commits intospec-v1/type-updatefrom
yarolegovich/remove-spec-nesting

Conversation

@yarolegovich
Copy link
Member

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yarolegovich, 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 streamlines the handling of security requirements within the a2a package by eliminating an intermediate struct and directly using a slice of maps. This refactoring enhances the clarity and efficiency of security configuration management, particularly for JSON operations, and includes necessary updates to data conversion logic and associated tests to reflect the new structure.

Highlights

  • Refactored Security Requirements Structure: The SecurityRequirement struct has been removed, and security requirements are now directly represented by SecurityRequirementsOptions, which is a slice of SecurityRequirements (a map of scheme names to scopes). This change simplifies the data model by removing an unnecessary layer of nesting.
  • Custom JSON Marshaling/Unmarshaling: Custom MarshalJSON and UnmarshalJSON methods were added to SecurityRequirementsOptions to correctly handle the JSON serialization and deserialization of the new flattened structure, ensuring compatibility with existing JSON representations.
  • Updated Conversion Logic: The fromProtoSecurity and toProtoSecurity functions in the pbconv package were updated to align with the new SecurityRequirementsOptions type, directly mapping protocol buffer security requirements to the simplified Go structure.
  • Code Formatting and Alignment: Several struct initializations across from_proto.go, to_proto.go, and to_proto_test.go were reformatted to improve readability by aligning field assignments.
Changelog
  • a2a/agent.go
    • Removed SecurityRequirement struct definition.
    • Updated SecurityRequirements field in AgentCard to use SecurityRequirementsOptions type.
    • Updated Security field in AgentSkill to use SecurityRequirementsOptions type.
  • a2a/auth.go
    • Added new type SecurityRequirements as a map of scheme names to scopes.
    • Added new type SecurityRequirementsOptions as a slice of SecurityRequirements.
    • Implemented MarshalJSON method for SecurityRequirementsOptions to handle JSON serialization.
    • Implemented UnmarshalJSON method for SecurityRequirementsOptions to handle JSON deserialization.
  • a2apb/v1/pbconv/from_proto.go
    • Updated fromProtoSecurity function signature and implementation to return a2a.SecurityRequirementsOptions.
    • Adjusted field alignment in a2a.Part struct initialization.
    • Adjusted field alignment in a2a.CreateTaskPushConfigRequest struct initialization.
    • Removed trailing space in FromProtoTaskPushConfig function.
    • Adjusted field alignment in a2a.ListTaskPushConfigRequest struct initialization.
    • Adjusted field alignment in a2a.AgentCapabilities struct initialization.
    • Adjusted field alignment in a2a.AuthorizationCodeOAuthFlow struct initialization.
    • Adjusted field alignment in a2a.ClientCredentialsOAuthFlow struct initialization.
    • Adjusted field alignment in a2a.ImplicitOAuthFlow struct initialization.
    • Adjusted field alignment in a2a.PasswordOAuthFlow struct initialization.
    • Adjusted field alignment in a2a.DeviceCodeOAuthFlow struct initialization.
    • Adjusted field alignment in a2a.AgentCard struct initialization.
    • Removed newline at end of file.
  • a2apb/v1/pbconv/to_proto.go
    • Adjusted field alignment in a2apb.SendMessageConfiguration struct initialization.
    • Adjusted field alignment in a2apb.CreateTaskPushNotificationConfigRequest struct initialization.
    • Adjusted field alignment in a2apb.Part struct initialization.
    • Adjusted field alignment in a2apb.ListTaskPushNotificationConfigRequest struct initialization.
    • Adjusted field alignment in a2apb.AgentCapabilities struct initialization.
    • Updated toProtoSecurity function signature and implementation to accept a2a.SecurityRequirementsOptions.
    • Adjusted field alignment in a2apb.AgentCard struct initialization.
  • a2apb/v1/pbconv/to_proto_test.go
    • Adjusted field alignment in a2a.Part test cases.
    • Adjusted field alignment in a2apb.TaskStatus test cases.
    • Adjusted field alignment in a2a.PushAuthInfo test cases.
    • Adjusted field alignment in a2apb.AuthenticationInfo test cases.
    • Adjusted field alignment in a2apb.TaskPushNotificationConfig test cases.
    • Adjusted field alignment in a2apb.TaskStatus test case.
    • Adjusted field alignment in a2a.AgentCard test case.
    • Updated SecurityRequirements in a2a.AgentCard test case to use a2a.SecurityRequirementsOptions.
    • Updated Security in a2a.AgentSkill test case to use a2a.SecurityRequirementsOptions.
    • Adjusted field alignment in a2apb.AgentCard test case.
    • Adjusted field alignment in a2a.AuthorizationCodeOAuthFlow test case.
    • Adjusted field alignment in a2a.ClientCredentialsOAuthFlow test case.
    • Adjusted field alignment in a2a.ImplicitOAuthFlow test case.
    • Adjusted field alignment in a2a.PasswordOAuthFlow test case.
    • Removed empty line in TestToProto_toProtoOAuthFlows.
    • Adjusted field alignment in a2a.Message test case.
    • Adjusted field alignment in a2apb.TaskStatus test case.
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.

@yarolegovich yarolegovich merged commit dd33c42 into spec-v1/type-update Feb 18, 2026
2 checks passed
@yarolegovich yarolegovich deleted the yarolegovich/remove-spec-nesting branch February 18, 2026 11:12
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 aims to remove a layer of nesting from the SecurityRequirement structure. The changes in the Go type definitions and protobuf conversions correctly reflect this. However, an issue was identified in a2a/auth.go where custom JSON marshalers for SecurityRequirementsOptions re-introduce a nesting layer for JSON serialization, contradicting the PR's intent and creating inconsistency with the now-flattened YAML serialization. This violates the rule that API definitions must follow the governing specification. It is recommended to remove these custom marshalers to achieve a truly flat structure in the JSON API. The other changes in the PR are mostly related to code formatting.

Comment on lines +35 to +60
func (rs SecurityRequirementsOptions) MarshalJSON() ([]byte, error) {
type wrapper struct {
Schemes map[SecuritySchemeName]SecuritySchemeScopes `json:"schemes"`
}
var out []wrapper
for _, req := range rs {
out = append(out, wrapper{Schemes: req})
}
return json.Marshal(out)
}

func (rs *SecurityRequirementsOptions) UnmarshalJSON(b []byte) error {
type wrapper struct {
Schemes map[SecuritySchemeName]SecuritySchemeScopes `json:"schemes"`
}
var wrapped []wrapper
if err := json.Unmarshal(b, &wrapped); err != nil {
return err
}
result := make(SecurityRequirementsOptions, 0, len(wrapped))
for _, w := range wrapped {
result = append(result, w.Schemes)
}
*rs = result
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The custom MarshalJSON and UnmarshalJSON methods for SecurityRequirementsOptions seem to contradict the goal of this pull request, which is to "remove schemes nesting". These methods re-introduce a nesting layer for JSON serialization, which seems to contradict the PR's intent and creates an inconsistency with the now-flattened YAML serialization. This goes against the principle that API definitions must follow the governing specification, prioritizing it over internal code consistency.

These methods wrap the map[SecuritySchemeName]SecuritySchemeScopes in a struct with a schemes field, resulting in a JSON structure like [{"schemes": {...}}]. This is very similar to the old structure which used a scheme key, and doesn't fully remove the nesting from the JSON representation.

If the goal is to truly flatten the structure, I recommend removing these custom marshalers. Without them, SecurityRequirementsOptions would serialize to [{"oauth2": ...}, {"mTLS": ...}], which is a cleaner and flatter API. Since a breaking change is already being introduced (by renaming scheme to schemes), it would be better to go with the simpler, flatter structure which aligns with the PR's title. This would also make the JSON serialization consistent with the YAML serialization, which is now flattened.

References
  1. API definitions must follow the governing specification, prioritizing it over internal code consistency.

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

Comments