Skip to content

fix(vertex): do not override custom http client when using vertex#238

Open
andreynering wants to merge 3 commits intoanthropics:mainfrom
charmbracelet:vertex-fixes
Open

fix(vertex): do not override custom http client when using vertex#238
andreynering wants to merge 3 commits intoanthropics:mainfrom
charmbracelet:vertex-fixes

Conversation

@andreynering
Copy link
Copy Markdown

@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
Copy Markdown
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 +114
default:
return nil, fmt.Errorf("vertex middleware does not support %s %s", r.Method, r.URL.Path)
Copy link
Copy Markdown
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
Copy Markdown
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!

@andreynering
Copy link
Copy Markdown
Author

I just rebased this.

This is the last piece that, if merged, would allow us to use the package directly on Fantasy and Crush without having to maintain a fork.

Let me know if it's not clear why we need this.

@andreynering
Copy link
Copy Markdown
Author

@gcemaj @nikblanchet It would be awesome to get this merged! 🙏

I'm happy to answer any questions.

We'd been using a fork instead of upstream just because of this small fix.

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