Skip to content

fix(storage): distinguish keychain user cancellation, auth failure, and error status from not-found#1144

Merged
datlechin merged 1 commit into
mainfrom
fix/keychain-distinguish-cancelled-and-auth-failures
May 9, 2026
Merged

fix(storage): distinguish keychain user cancellation, auth failure, and error status from not-found#1144
datlechin merged 1 commit into
mainfrom
fix/keychain-distinguish-cancelled-and-auth-failures

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • KeychainResult and KeychainStringResult gain three new cases: .userCancelled, .authFailed, .error(OSStatus).
  • KeychainHelper.read(forKey:) now maps errSecUserCanceled and errSecAuthFailed to their own cases and routes any other unknown OSStatus to .error(status) instead of pretending it was .notFound.
  • readStringResult(forKey:) propagates the new cases and returns .error(errSecDecode) (not .notFound) when the bytes are not valid UTF-8.
  • All four read sites (connection passwords / SSH profile secrets / AI provider keys / license key) handle every case with a distinct OSLog line and continue to return nil to the caller.

Why this matters

This is bug B4 from the full-app audit. A cancelled Touch ID prompt returns errSecUserCanceled; previously the default: arm collapsed it to .notFound, the caller treated the password as gone and re-prompted the user. The user re-types the password, the keychain ends up with two entries, or the connection gets re-saved with a blank password. The new cases let callers tell apart "I never had this saved" from "the user just cancelled" from "biometric auth failed" from "real keychain error", and the OSLog signal makes the failure mode diagnosable.

Test plan

  • Cancel a Touch ID prompt, confirm log line Keychain prompt cancelled for 'com.TablePro.password.<id>' appears and the connection is not re-saved with a blank password.
  • Connection / SSH profile / AI key / license-key paths each load normally when the keychain entry is present.
  • swiftlint --strict clean.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin datlechin merged commit 8dcb478 into main May 9, 2026
2 checks passed
@datlechin datlechin deleted the fix/keychain-distinguish-cancelled-and-auth-failures branch May 9, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant