Support --asn for ISP proxies - #213
Conversation
--asn was registered on every proxy type but only wired into residential and mobile, so passing it with --type isp silently dropped it and returned a proxy on an arbitrary network. Wires --asn into the ISP config, and makes the types that cannot honour it (datacenter, custom, mobile) fail with a clear error instead of ignoring it. Mobile previously warned and continued for --zip/--asn, which the API rejects anyway, so both are now errors. Requires the SDK bump that adds Asn to ProxyNewParamsConfigIsp. Co-authored-by: Cursor <cursoragent@cursor.com>
🔧 CI Fix AvailableI've pushed a fix for the CI failure. What failed: Why: the commit notes this "requires the SDK bump that adds Fix: send if in.ASN != "" {
config.SetExtraFields(map[string]any{"asn": in.ASN})
}The two ISP tests now assert on
|
The generated ProxyNewParamsConfigIsp has no Asn field, so the previous commit did not build against the pinned SDK. Send asn via SetExtraFields, which produces the same request body, so the flag works against the deployed API without waiting on a Stainless release. Tests now assert on the serialized request rather than the struct field, so they keep verifying the wire format once asn becomes a generated field. Co-authored-by: Cursor <cursoragent@cursor.com>
Problem
kernel proxy create --type isp --name ulzii-asn --asn AS6079returned a proxy on AS11426, not AS6079, and said nothing about it.--asnis registered on thecreatecommand for every type, but was only wired into the request forresidentialandmobile. Theispbranch built a config containingcountryand nothing else, so the flag never left the machine. The types that genuinely can't honour it were no better:datacenterandcustomignored it entirely, andmobileprinted a warning and continued.Change
--asnnow flows into the ISP config.datacenter,custom, andmobilefail with a clear error rather than dropping the flag. Mobile previously warned and continued for--zip/--asn; the API rejects both, so the CLI now matches instead of building a request the server will refuse.Server-side support is kernel/kernel#3059, which validates the ASN against the pool and returns the available ASNs when it isn't there.
On the extra field
ProxyNewParamsConfigIspin the pinned SDK (v0.85.0) has noAsnfield yet — Stainless only regenerates once the spec change in kernel/kernel#3059 merges. Rather than block this PR on that release, the ASN is sent viaSetExtraFields, which produces an identical request body:{"type":"isp","name":"RCN ISP","config":{"country":"US","asn":"AS6079"}}This is marked with a comment to swap for
config.Asnon the next SDK bump. The tests assert on the serialized request rather than the struct field, so they keep verifying the wire format unchanged onceasnbecomes generated.Ordering note: this is safe to merge before or after #3059. Until the API side ships,
--asnon an ISP proxy is simply ignored by the server, which is today's behaviour.Test plan
go build ./...andgo vet ./...clean against the unpatched SDK v0.85.0go test ./...— full suite passesconfig.asnis present and does not displacecountry--country; ISP omits it when not requested (so an empty string is never sent, which the API would reject as malformed); datacenter/mobile/custom reject--asnwithout issuing a request; mobile rejects--zipSetExtraFieldswithconfig.AsnNote
Low Risk
CLI-only proxy create validation and request shaping; no auth or infrastructure changes, with tests locking the wire format.
Overview
kernel proxies create --asnnow reaches the API for ISP proxies instead of being dropped on the floor. The value is sent on the ISP config viaSetExtraFieldsuntil the Go SDK gains a typedAsnfield.Unsupported proxy types no longer silently ignore the flag. Datacenter, custom, and mobile return a clear error if
--asnis set; mobile also errors on--zipinstead of warning and continuing with a request the API would reject.README and
--asnflag help are updated (ISP/residential scope, pool constraints), with an ISP create example. New tests cover ISP wire format, omission when unset, and rejection paths for unsupported types.Reviewed by Cursor Bugbot for commit ac173c5. Bugbot is set up for automated code reviews on this repo. Configure here.