fix(archied): disable a provider whose credential is missing instead of refusing to boot
configuration.md's startup policy -- "a missing credential disables a capability.
Only an invalid config stops the daemon" -- names this exact case: "Apply the same
reasoning to any future capability credential, LLM keys especially: start, report
the capability as unavailable, let the operator see it." The code did the
opposite. resolveProviderMap returned an error when a provider's api_key could not
be resolved, and again when it resolved empty, so configuredSecretRegistry failed
and the daemon would not start. A provider nobody referenced still blocked boot,
because the walk covers every entry in cfg.Providers rather than the ones [models]
uses.
The forge path was fixed to degrade for precisely this reason (resolveForge,
guarded by TestResolveForgeDegradesInsteadOfFailing); this is its provider
counterpart. A credential that cannot be resolved now disables that provider with
a warning naming it and why, and the daemon starts.
Disabling clears the reference rather than leaving it. webui's ProviderView
derives Configured from api_key or APIKeyEnv, so an unresolvable reference left in
place would advertise a provider nothing can use -- the "looks configured and is
not" shape this codebase keeps having to remove. Consumers already treat an empty
APIKeyEnv as no credential (agentexec/runtime skips such a provider, the daemon
exports nothing to the agent container), so clearing it is the whole disable.
The other half of the policy is kept: a reference naming only one of engine and
key is a config error, not a missing credential, and stays fatal.
applyForgeDefaults only ever builds a ref with both halves, so a half-named one can
only come from a hand-edited config.
This also defuses the trap 027dc99 introduced. archied setup can now write a
provider reference to any engine (-provider-secret-ref bws:OPENAI_API_KEY), and on
a machine without that engine the config used to load clean and then brick the
daemon. It now starts with that provider disabled and a warning.
The comment on templateDefaultActiveProvider described the old fatal behaviour and
is corrected rather than left to mislead the next reader.
All three behaviours are mutation-verified: returning an error again, accepting a
half-named reference, and disabling without clearing the reference each fail the
corresponding test. The red was an assertion failure, not a compile error -- the
logger parameter was threaded through first so the new test could be run against
unchanged behaviour.
This commit is contained in:
3 files changed
+152
-21
No files matched your search
@@ -35,14 +35,13 @@ var cloudProviders = []cloudProvider{
|
||||
// templateDefaultActiveProvider is the one provider table config.example.
|
||||
// toml ships active by default: [providers.openai], with
|
||||
// api_key = {engine="bws", key="OPENAI_API_KEY"}. bws is compiled in but
|
||||
// requires the bws CLI on PATH; on a machine without it (the common case),
|
||||
// resolving that key errors, and cmd/archied/provider_secrets.go's
|
||||
// resolveProviderSecrets walks every entry in cfg.Providers -- not just
|
||||
// the ones [models] actually references -- and refuses to start the
|
||||
// daemon at all if any of them fails to resolve. Choosing any provider
|
||||
// other than OpenAI, or choosing OpenAI but leaving its key blank, must
|
||||
// neutralise this table rather than leave it as a silent boot-time
|
||||
// landmine nothing in setup's own output would explain.
|
||||
// requires the bws CLI on PATH; on a machine without it (the common case)
|
||||
// resolving that key fails, and resolveProviderSecrets disables the provider
|
||||
// with a warning rather than stopping the daemon. Neutralising the table is
|
||||
// still setup's business: a provider the operator never chose should not be
|
||||
// left advertised and unusable, with a warning they did not cause. Choosing any
|
||||
// provider other than OpenAI, or choosing OpenAI but leaving its key blank,
|
||||
// therefore replaces this table.
|
||||
const templateDefaultActiveProvider = "openai"
|
||||
|
||||
func stepProvider(ctx context.Context, p Prompter, discovery ModelDiscovery, secrets SecretSink, params Params) (tableEdits, string, error) {
|
||||
|
||||
Reference in new issue
Block a user