File and Lines
desktop/wailskit/config.go:313
Problem Description
SaveAPIKey discards the error returned by SetEndpointAPIKey:
func SaveAPIKey(vendor, endpoint, apiKey string) error {
// ...
cfg.SetEndpointAPIKey(vendor, endpoint, apiKey, vendorScoped) // error discarded!
return cfg.Save()
}
SetEndpointAPIKey returns errors in multiple conditions (confirmed in internal/config/config_keys.go):
c == nil → "config is nil"
- Vendor not in
c.Vendors → "vendor %q is not configured"
- Endpoint not found (non-vendorScoped) →
"endpoint %q is not configured for vendor %q"
When SetEndpointAPIKey fails, the config is unchanged. cfg.Save() then succeeds (writes unchanged config), and SaveAPIKey returns nil — reporting success to the frontend even though the key was never persisted.
Trigger Scenario
- Vendor
"zai" has multiple endpoints (so vendorScoped = false)
- Frontend sends an endpoint name that doesn't match config (e.g., renamed/deleted endpoint, or case mismatch)
SetEndpointAPIKey("zai", "wrong-name", key, false) returns error
- Error is discarded by
SaveAPIKey
cfg.Save() succeeds (writes unchanged config)
- Frontend shows "API key saved" — but key was never persisted
- All subsequent API calls fail with auth errors
Expected vs Actual Behavior
- Expected: Error from
SetEndpointAPIKey is propagated to caller
- Actual: Error is silently discarded, success reported
Fix Suggestion
if err := cfg.SetEndpointAPIKey(vendor, endpoint, apiKey, vendorScoped); err != nil {
return err
}
return cfg.Save()
Severity
Medium — Silent failure on credential management path. User believes key was saved when it wasn't.
Verification
Independently verified by subagent sa-174:
- Confirmed
SetEndpointAPIKey returns errors in config_keys.go lines 16-22, 33-34, 66-68
- Confirmed
SaveAPIKey has no fallback path — line 313 is the only SetEndpointAPIKey call
- Confirmed desktop frontend
SettingsPage.tsx sets apiKeySet(true) after SaveAPIKey returns nil
File and Lines
desktop/wailskit/config.go:313Problem Description
SaveAPIKeydiscards the error returned bySetEndpointAPIKey:SetEndpointAPIKeyreturns errors in multiple conditions (confirmed ininternal/config/config_keys.go):c == nil→"config is nil"c.Vendors→"vendor %q is not configured""endpoint %q is not configured for vendor %q"When
SetEndpointAPIKeyfails, the config is unchanged.cfg.Save()then succeeds (writes unchanged config), andSaveAPIKeyreturnsnil— reporting success to the frontend even though the key was never persisted.Trigger Scenario
"zai"has multiple endpoints (sovendorScoped = false)SetEndpointAPIKey("zai", "wrong-name", key, false)returns errorSaveAPIKeycfg.Save()succeeds (writes unchanged config)Expected vs Actual Behavior
SetEndpointAPIKeyis propagated to callerFix Suggestion
Severity
Medium — Silent failure on credential management path. User believes key was saved when it wasn't.
Verification
Independently verified by subagent sa-174:
SetEndpointAPIKeyreturns errors inconfig_keys.golines 16-22, 33-34, 66-68SaveAPIKeyhas no fallback path — line 313 is the onlySetEndpointAPIKeycallSettingsPage.tsxsetsapiKeySet(true)afterSaveAPIKeyreturns nil