feat(ai): add proxy and custom CA support for enterprise environments#85
feat(ai): add proxy and custom CA support for enterprise environments#85himanshu2394i wants to merge 1 commit into
Conversation
|
🚀 First PR — welcome aboard! A few things to expect:
If you get stuck, reply here or jump to Discussions. We want this PR to land. |
Signed-off-by: Himanshu <himanshu1908999@gmail.com>
965fe3b to
57fe1c4
Compare
|
@btwshivam Can you review it? |
btwshivam
left a comment
There was a problem hiding this comment.
the http client and config are solid, but the new fields are never wired into the real providers, so custom CA, proxy, and timeout do nothing in production. thread them through buildAnalyzer and explain, details inline.
| // Temperature default. | ||
| Temperature float64 | ||
|
|
||
| Timeout time.Duration |
There was a problem hiding this comment.
these new fields are never populated by the real callers. buildAnalyzer (doctor.go:413) and explain.go:88 both build ProviderConfig{Name, Model, APIKey, Endpoint, MaxTokens, Temperature} and don't copy aiCfg.Timeout / Proxy / CACertFile / InsecureSkipVerify, and this PR doesn't touch either file. so every provider gets the zero values: Timeout: 0 (no timeout), CACertFile: "" (custom CA does nothing), Proxy: "". the headline #47 features are dead through the only paths that build providers. your tests pass because they call NewHTTPClient directly with explicit args. add the four fields to both ProviderConfig literals.
| } | ||
| //nolint:gosec // CA certificate path is intentionally user-configurable via trusted config. | ||
| caCert, err := os.ReadFile(caCertFile) | ||
| if err == nil { |
There was a problem hiding this comment.
CA load failures are swallowed here. if os.ReadFile errors or AppendCertsFromPEM returns false (bad path, wrong perms, malformed PEM), the function silently keeps the system pool and returns a client as if nothing happened. the operator then gets a confusing TLS failure with no hint the CA was never loaded. Validate os.Stats the file but doesn't parse it. since NewHTTPClient can't return an error today, either change the signature to return one, or validate the PEM in config so a bad cert fails fast.
| ) *http.Client { | ||
| //nolint:gosec // InsecureSkipVerify is intentionally configurable for local/dev and air-gapped environments. | ||
| tlsConfig := &tls.Config{ | ||
| InsecureSkipVerify: insecureSkipVerify, |
There was a problem hiding this comment.
|
any updates? |
What
Add enterprise-grade HTTP client support for AI providers, including:
Why
Fixes #47
AI features are a core differentiator for Kerno, but enterprise deployments often route outbound HTTPS traffic through TLS-inspecting corporate proxies using custom root CAs. Without configurable proxy and CA support, AI integrations fail in regulated and Fortune 500 environments.
How
internal/ai/http_client.goto centralize HTTP client creationai.proxyai.ca_cert_fileai.insecure_skip_verifyai.timeoutHTTPS_PROXYHTTP_PROXYNO_PROXYTesting
go build ./...passesgo test ./...passesgo vet ./...passesgolangci-lint run ./...passesTested locally with:
go test ./internal/ai/... -vN/A — pure docs/refactor
Checklist
feat(scope): subject)git commit -s)