Skip to content

Conversation

@andreynering
Copy link

@andreynering andreynering commented Sep 25, 2025

We've been using the go-vcr library to handle HTTP requests inside tests, and it gives you a custom HTTP transport, but the SDK also sets one. This PR combine both transports so they work together!

vertex/vertex.go Outdated
sdkoption.WithBaseURL(baseURL),
sdkoption.WithMiddleware(middleware),
sdkoption.WithHTTPClient(client),
sdkoption.WithHTTPClient(&http.Client{Transport: transport}),
Copy link
Author

@andreynering andreynering Sep 25, 2025

Choose a reason for hiding this comment

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

We need a custom HTTP client here, but this package was essetially overriding it, making our custom client useless.

Here, I'm trying to combine both transports, but I'm sure yet if this is the best way to accomplish it. Seems to have worked well for us, though.

TODO: Handle scenario where rc.HTTPClient is nil. (Probably fallback to the previous code). Done!

Comment on lines +113 to +120
default:
return nil, fmt.Errorf("vertex middleware does not support %s %s", r.Method, r.URL.Path)
Copy link
Author

Choose a reason for hiding this comment

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

Looks like if we miss any path, we probably forgot something in the code. A good idea to error here?

@andreynering andreynering marked this pull request as ready for review October 10, 2025 14:31
@andreynering andreynering requested a review from a team as a code owner October 10, 2025 14:31
@andreynering andreynering force-pushed the vertex-fixes branch 2 times, most recently from 7419bf6 to 7b952cd Compare October 10, 2025 17:21
@andreynering andreynering changed the title fix(vertex): make general fixes for vertex fix(vertex): do not override custom http client when using vertex Oct 10, 2025
@andreynering
Copy link
Author

@gcemaj I wonder if you can take a look at this when possible? We're using a fork in the meantime because we need this. Thanks!

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