chore: temp fix module id v1 suffix#254
Conversation
Summary of ChangesHello, 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 implements a temporary fix by reverting the Go module path to its original form, addressing potential conflicts when modules attempt to self-import older versions. The change necessitated a broad update of import statements across the codebase, particularly within the compatibility layer for older API versions. Additionally, the compatibility layer itself underwent refactoring to use internal types, and related tests and migration utilities were removed or updated. The documentation and example code were also adjusted to reflect these module path and API changes. Highlights
Changelog
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request is a large-scale refactoring that removes the /v1 suffix from the module path and all import paths across the repository. This is a significant but necessary change to resolve Go module versioning issues. As part of this, the compatibility package a2acompat/a2av0 has been refactored to vendor its own legacy types instead of depending on an older version of the module, which is a good improvement for maintainability. I've suggested a small improvement for robustness in one of the new conversion functions.
| switch f := c.File.(type) { | ||
| case fileBytes: | ||
| bytes, err := base64.StdEncoding.DecodeString(f.Bytes) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to decode base64 content: %w", err) | ||
| } | ||
| res[i] = &a2a.Part{ | ||
| Content: a2a.Raw(bytes), | ||
| Metadata: c.Metadata, | ||
| MediaType: f.MimeType, | ||
| Filename: f.Name, | ||
| } | ||
| case fileURI: | ||
| res[i] = &a2a.Part{ | ||
| Content: a2a.URL(f.URI), | ||
| Metadata: c.Metadata, | ||
| MediaType: f.MimeType, | ||
| Filename: f.Name, | ||
| } | ||
| } |
There was a problem hiding this comment.
The inner switch statement for filePart does not have a default case. While the UnmarshalJSON for filePart seems to ensure that c.File is either fileBytes or fileURI, it's safer to handle unexpected types explicitly. This would make the code more robust against future changes and prevent potential nil pointer issues if an unsupported filePartContent type is ever introduced.
switch f := c.File.(type) {
case fileBytes:
bytes, err := base64.StdEncoding.DecodeString(f.Bytes)
if err != nil {
return nil, fmt.Errorf("failed to decode base64 content: %w", err)
}
res[i] = &a2a.Part{
Content: a2a.Raw(bytes),
Metadata: c.Metadata,
MediaType: f.MimeType,
Filename: f.Name,
}
case fileURI:
res[i] = &a2a.Part{
Content: a2a.URL(f.URI),
Metadata: c.Metadata,
MediaType: f.MimeType,
Filename: f.Name,
}
default:
return nil, fmt.Errorf("unsupported file part content type: %T", f)
}This reverts commit b964514.
…on (#262) ## Description Ref #257 🦕 ### Motivation The `a2asrv/` server package does not include testable examples (`Example_*` functions). Usage snippets exist in the README and `doc.go`, but they are not executable, not validated by `go test`, and do not render as function-level examples on **pkg.go.dev**. ### Changes Add `a2asrv/example_test.go` using `package a2asrv_test` (external test package), following Go's `ExampleXxx` / `ExampleType_Method` naming convention. Examples added for the following public API surface: | Function / Type | Example demonstrates | |---|---| | `NewHandler` | Creating a basic request handler with an `AgentExecutor` | | `NewHandler` (withOptions) | Creating a handler with `WithExtendedAgentCard` and `WithCallInterceptors` | | `NewJSONRPCHandler` | Wrapping a handler with JSON-RPC transport and registering with `http.ServeMux` | | `NewStaticAgentCardHandler` | Serving a static `AgentCard` via httptest and verifying JSON response | | `NewAgentCardHandler` | Serving a dynamic `AgentCard` via an `AgentCardProducerFn` | | `WellKnownAgentCardPath` | Displaying the standard well-known path constant | | `WithCallInterceptors` | Adding server-side middleware to a handler | | `PassthroughCallInterceptor` | Demonstrating the no-op `Before`/`After` interceptor lifecycle | | `NewCallContext` | Creating a call context with `ServiceParams` and reading request metadata | | `NewServiceParams` | Case-insensitive service parameter lookups | | `CallContext.Extensions` | Requesting, activating, and inspecting extensions | All examples include `// Output:` comments and are validated by `go test`. ### Tests The examples themselves are tests — validated through output matching. All 12 pass. Existing tests are unaffected. ``` go test ./a2asrv/ -v -run Example ``` ### Additional context Import paths follow the current module declaration (`github.com/a2aproject/a2a-go`), consistent with the temporary revert in #254 (ref #250). Happy to update if the module path changes. This is the first of two PRs addressing #257. The second PR will add examples for `a2aclient/`. --------- Co-authored-by: Yaroslav <yarolegovich@gmail.com>
…ation (#263) ## Description Ref #257 🦕 ### Motivation The `a2aclient/` client package does not include testable examples (`Example_*` functions). Usage snippets exist in the README, but they are not executable, not validated by `go test`, and do not render as function-level examples on **pkg.go.dev**. ### Changes Add `a2aclient/example_test.go` using `package a2aclient_test` (external test package), following Go's `ExampleXxx` / `ExampleType_Method` naming convention. Examples added for the following public API surface: | Function / Type | Example demonstrates | |---|---| | `NewFromCard` | Creating a client from an `AgentCard` (with live httptest server) | | `NewFromEndpoints` | Creating a client from known `AgentInterface` endpoints | | `NewFactory` | Setting up a reusable client factory | | `NewFactory` (withConfig) | Factory with `PreferredTransports` configuration | | `Factory.CreateFromCard` | Using factory to create a client from a card | | `Factory.CreateFromEndpoints` | Using factory to create a client from endpoints | | `WithJSONRPCTransport` | Configuring JSON-RPC transport with a custom `http.Client` | | `Resolver.Resolve` | Resolving an `AgentCard` from a URL via `agentcard.DefaultResolver` | | `NewResolver` | Creating a resolver with a custom `http.Client` | | `AuthInterceptor` | Setting up credential-based auth with `InMemoryCredentialsStore` and adding it to a factory via `WithCallInterceptors` | | `WithAdditionalOptions` | Extending a base factory with additional options | All examples include `// Output:` comments and are validated by `go test`. ### Tests The examples themselves are tests — validated through output matching. Existing tests are unaffected. ``` go test ./a2aclient/ -v -run Example ``` ### Additional context Import paths follow the current module declaration (`github.com/a2aproject/a2a-go`), consistent with the temporary revert in #254 (ref #250). Happy to update if the module path changes. This is the second of two PRs addressing #257, following the a2asrv/ examples PR (#262). If there are other packages where this kind of testable examples would be useful, happy to pick them up. --------- Co-authored-by: Yaroslav <yarolegovich@gmail.com>
Temporarily revert changes which add v1 suffix for self-importing older version.
re #250