Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.51.0"
".": "0.52.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 112
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-a674e3c4c0063942621d1b4e7f67b72f7e240c12dd88564fe16627618ba33dd6.yml
openapi_spec_hash: 8b97c87f0dafe5fc5e5a7365f3687755
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-4ce09d1a7546ab36f578cb27d819187eeb90c580b11834c7ff7a375aa22f9a20.yml
openapi_spec_hash: 1043ab2d699f6c828680c3352cd4cece
config_hash: 08d55086449943a8fec212b870061a3f
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 0.52.0 (2026-04-29)

Full Changelog: [v0.51.0...v0.52.0](https://github.com/kernel/kernel-go-sdk/compare/v0.51.0...v0.52.0)

### Features

* **go:** add default http client with timeout ([a999228](https://github.com/kernel/kernel-go-sdk/commit/a999228cc4426709eb1561f6cf46d51833509014))
* profile download: 409 for empty profile + surface API errors in dashboard ([c14aef2](https://github.com/kernel/kernel-go-sdk/commit/c14aef289c5418906fb003893a728ec11cf549cc))
* support setting headers via env ([728fe39](https://github.com/kernel/kernel-go-sdk/commit/728fe3931a9a8b9f7de3ef6f338c3872fb67c4b1))

## 0.51.0 (2026-04-25)

Full Changelog: [v0.50.0...v0.51.0](https://github.com/kernel/kernel-go-sdk/compare/v0.50.0...v0.51.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/kernel/kernel-go-sdk@v0.51.0'
go get -u 'github.com/kernel/kernel-go-sdk@v0.52.0'
```

<!-- x-release-please-end -->
Expand Down
11 changes: 10 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"os"
"slices"
"strings"

"github.com/kernel/kernel-go-sdk/internal/requestconfig"
"github.com/kernel/kernel-go-sdk/lib/browserrouting"
Expand Down Expand Up @@ -48,13 +49,21 @@ type Client struct {
// DefaultClientOptions read from the environment (KERNEL_API_KEY,
// KERNEL_BASE_URL). This should be used to initialize new clients.
func DefaultClientOptions() []option.RequestOption {
defaults := []option.RequestOption{option.WithEnvironmentProduction()}
defaults := []option.RequestOption{option.WithHTTPClient(defaultHTTPClient()), option.WithEnvironmentProduction()}
if o, ok := os.LookupEnv("KERNEL_BASE_URL"); ok {
defaults = append(defaults, option.WithBaseURL(o))
}
if o, ok := os.LookupEnv("KERNEL_API_KEY"); ok {
defaults = append(defaults, option.WithAPIKey(o))
}
if o, ok := os.LookupEnv("KERNEL_CUSTOM_HEADERS"); ok {
for _, line := range strings.Split(o, "\n") {
colon := strings.Index(line, ":")
if colon >= 0 {
defaults = append(defaults, option.WithHeader(strings.TrimSpace(line[:colon]), strings.TrimSpace(line[colon+1:])))
}
}
}
return defaults
}

Expand Down
24 changes: 24 additions & 0 deletions default_http_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package kernel

import (
"net/http"
"time"
)

// defaultResponseHeaderTimeout bounds the time between a fully written request
// and the server's response headers. It does not apply to the response body,
// so long-running streams are unaffected. Without this, a server that accepts
// the connection but never responds would hang the request indefinitely.
const defaultResponseHeaderTimeout = 10 * time.Minute

// defaultHTTPClient returns an [*http.Client] used when the caller does not
// supply one via [option.WithHTTPClient]. It clones [http.DefaultTransport]
// and adds a [http.Transport.ResponseHeaderTimeout] so stuck connections
// fail fast instead of compounding across retries.
func defaultHTTPClient() *http.Client {
transport := http.DefaultTransport.(*http.Transport).Clone()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unchecked type assertion may panic on initialization

Medium Severity

The expression http.DefaultTransport.(*http.Transport) is an unchecked type assertion that will panic if http.DefaultTransport has been replaced with a non-*http.Transport implementation (e.g., by test mocking libraries like httpmock or gock, or custom middleware). Since this runs during NewClient() initialization, the panic is unrecoverable. The rest of the codebase (e.g., rawcurl.go) safely uses http.DefaultTransport via the RoundTripper interface without asserting the concrete type. Using the comma-ok form of the assertion would allow a graceful fallback.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4d8d254. Configure here.

transport.ResponseHeaderTimeout = defaultResponseHeaderTimeout
return &http.Client{Transport: transport}
}
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "0.51.0" // x-release-please-version
const PackageVersion = "0.52.0" // x-release-please-version
3 changes: 1 addition & 2 deletions profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ func (r *ProfileService) Delete(ctx context.Context, idOrName string, opts ...op
return err
}

// Download the profile. Profiles are JSON files containing the pieces of state
// that we save.
// Returns a zstd-compressed tar file of the full user-data directory.
func (r *ProfileService) Download(ctx context.Context, idOrName string, opts ...option.RequestOption) (res *http.Response, err error) {
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "application/octet-stream")}, opts...)
Expand Down
Loading