The State Store wire described a provider's class, base URL and key variable but never where its key lives, so every provider reached the daemon credential-less. A task then built its runtime with no key: the egress session had nothing to bind and the agent parked on 'APIKey is required'. Carry api_key_engine and api_key_key alongside the provider. They are a reference, not a secret; the key is still resolved daemon-side and never travels to a container.
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package staterpc
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/samcharles93/archie-core/internal/config"
|
|
)
|
|
|
|
// A provider's credential reference must survive the State Store wire. It is a
|
|
// reference, not a secret: the daemon needs it to resolve the key for a model
|
|
// egress session, and without it every provider arrives credential-less and a
|
|
// run is built with no runtime key at all.
|
|
func TestModelProviderWireCarriesCredentialRef(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
sent := map[string]config.Provider{
|
|
"remote": {
|
|
Class: "deepseek",
|
|
BaseURL: "https://example.invalid/v1",
|
|
APIKeyEnv: "REMOTE_API_KEY",
|
|
APIKey: config.SecretRef{Engine: "bws", Key: "REMOTE_SECRET"},
|
|
},
|
|
"local": {
|
|
Class: "ollama",
|
|
BaseURL: "http://127.0.0.1:5800/v1",
|
|
},
|
|
}
|
|
|
|
got := map[string]config.Provider{}
|
|
for name, provider := range sent {
|
|
got[name] = modelProviderFromPB(modelProviderToPB(provider))
|
|
}
|
|
|
|
for name, want := range sent {
|
|
if got[name] != want {
|
|
t.Errorf("provider %q round-trip = %+v, want %+v", name, got[name], want)
|
|
}
|
|
}
|
|
if got["remote"].APIKey != (config.SecretRef{Engine: "bws", Key: "REMOTE_SECRET"}) {
|
|
t.Errorf("credential reference was dropped on the wire: %+v", got["remote"].APIKey)
|
|
}
|
|
}
|