FluidVoice icon indicating copy to clipboard operation
FluidVoice copied to clipboard

[🐞 BUG] Custom AI provider settings are regularly lost

Open veged opened this issue 10 months ago • 3 comments

Describe the bug Custom AI provider settings are regularly lost. When I open the settings, the entire list of providers disappears, including my custom provider, and my custom prompt is also missing. After adding a custom provider again, the previously filled custom prompts reappear.

To Reproduce Steps to reproduce the behavior:

  1. Go to Preferences → AI Enhancements → Providers and Prompts & Advanced
  2. Add custom provider and custom Dictation Prompt
  3. After few successful dictations Fluid starts act without those settings and if you open Preferences → AI Enhancements again it will be empty (even without predefined providers)

Expected behavior Stable AI Enhancements settings

Screenshots

Image

Environment:

  • macOS Version: Sequoia 15.7.3 (24G419)
  • App Version: v1.5.5
  • Architecture: Apple Silicon

Additional context Add any other context about the problem here.

Logs

[18:04:10.516] [ERROR] [SettingsStore] Failed to persist provider API keys: One or more parameters passed to a function were not valid.
[18:04:18.522] [ERROR] [SettingsStore] Failed to persist provider API keys: One or more parameters passed to a function were not valid.
[18:04:18.537] [DEBUG] [AISettingsView] testAPIConnection: provider=openrouter, model=anthropic/claude-sonnet-4.5, baseURL=https://openrouter.ai/api/v1, fullURL=https://openrouter.ai/api/v1/chat/completions

veged avatar Jan 28 '26 14:01 veged

Oh wow. This is a pretty crazy bug for sure. Is this random? Do the builtin ones ever come back after disappearing? Can you reproduce it? I have never seen this till now. If you could help me some way to reproduce it, it would be amazing! Thanks

altic-dev avatar Jan 28 '26 16:01 altic-dev

Oh wow. This is a pretty crazy bug for sure. Is this random? Do the builtin ones ever come back after disappearing? Can you reproduce it? I have never seen this till now. If you could help me some way to reproduce it, it would be amazing! Thanks

It's 100% stable — after any moves away from AI Enhancement window (close settings or switching tab). I suspect my custom Russian prompt, since it's the first "unusual" thing in whole setup... Could you also made logs more informative about: "[18:04:10.516] [ERROR] [SettingsStore] Failed to persist provider API keys: One or more parameters passed to a function were not valid."? Which exactly parameters?

veged avatar Jan 28 '26 20:01 veged

I can reproduce/trace the log:

[SettingsStore] Failed to persist provider API keys: One or more parameters passed to a function were not valid.

This comes from SettingsStore.providerAPIKeys setter calling persistProviderAPIKeys(_:), which delegates to Keychain.

Relevant code:

  • SettingsStore.providerAPIKeys setter → persistProviderAPIKeys(newValue)[1]
  • SettingsStore.persistProviderAPIKeys(_:) → try self.keychain.storeAllKeys(trimmed)[1]

In KeychainService.saveStoredKeys, the errSecDuplicateItem branch uses SecItemUpdate with an update “dictionary” that looks malformed and can return errSecParam (“One or more parameters…”) on some systems:

case errSecDuplicateItem:
    let updateStatus = SecItemUpdate(
        aggregatedQuery() as CFDictionary,
        [kSecValueData as String: data] as CFDictionary
    )

Possible fix: pass a properly typed [String: Any] attributes dictionary (and keep kSecAttrAccessible consistent with the SecItemAdd path):

case errSecDuplicateItem:
    let update: [String: Any] = [
        kSecValueData as String: data,
        kSecAttrAccessible as String: kSecAttrAccessibleAfterFirstUnlock
    ]
    let updateStatus = SecItemUpdate(
        aggregatedQuery() as CFDictionary,
        update as CFDictionary
    )
    guard updateStatus == errSecSuccess else {
        throw KeychainServiceError.unhandledOSStatus(updateStatus)
    }

Also, for easier debugging, it might help to log the raw OSStatus (nsError.code) in the catch inside SettingsStore.persistProviderAPIKeys(_:) (right now it logs only localizedDescription).

veged avatar Jan 29 '26 07:01 veged