Context
Identified in PR #5142 review by @JAORMX and Copilot.
Problem
llmValueForSpec in pkg/client/llm_gateway.go has a default: case that writes the ValueField string verbatim as a literal value when it doesn't match any known resolver. This is currently used intentionally for gemini-api-key in the Gemini CLI config entry.
The foot-gun: a typo in any known ValueField (e.g. "GatwayURL" instead of "GatewayURL") silently writes the typo as a literal string into the user's settings file — no error, no test catches it.
Additionally, the doc comment on LLMGatewayKeySpec says "Exactly one of ValueField or Literal must be set", but the code does not enforce mutual exclusion (Literal wins if both are set).
Suggested fix
Add an explicit Literal field to LLMGatewayKeySpec:
type LLMGatewayKeySpec struct {
JSONPointer string
ValueField string // must be empty when Literal is set
Literal string // written verbatim; must be empty when ValueField is set
ClearWhenEmpty bool
}
And validate at startup (or in llmValueForSpec) that exactly one of ValueField/Literal is non-empty. Unknown ValueField values should return an error rather than being silently treated as literals.
The Gemini CLI entry becomes:
{JSONPointer: "/security/auth/selectedType", Literal: "gemini-api-key"},
References
Context
Identified in PR #5142 review by @JAORMX and Copilot.
Problem
llmValueForSpecinpkg/client/llm_gateway.gohas adefault:case that writes theValueFieldstring verbatim as a literal value when it doesn't match any known resolver. This is currently used intentionally forgemini-api-keyin the Gemini CLI config entry.The foot-gun: a typo in any known
ValueField(e.g."GatwayURL"instead of"GatewayURL") silently writes the typo as a literal string into the user's settings file — no error, no test catches it.Additionally, the doc comment on
LLMGatewayKeySpecsays "Exactly one of ValueField or Literal must be set", but the code does not enforce mutual exclusion (Literal wins if both are set).Suggested fix
Add an explicit
Literalfield toLLMGatewayKeySpec:And validate at startup (or in
llmValueForSpec) that exactly one ofValueField/Literalis non-empty. UnknownValueFieldvalues should return an error rather than being silently treated as literals.The Gemini CLI entry becomes:
{JSONPointer: "/security/auth/selectedType", Literal: "gemini-api-key"},References
pkg/client/llm_gateway.gopkg/client/config.go(line 163, doc contract nit)pkg/client/config.go(literal-value behavior undocumented)