Skip to content

Decoding error when loading amplify credentials: KeychainStoreError #3937

@andr3a88-amk

Description

@andr3a88-amk

Describe the bug

Hi, I've updated Amplify Swift from 2.43.0 to 2.45.1. When I run my app with the updated of Amplify I cannot fetch the access token (causing a force logout to the user). I fetch the access token calling cognitoTokenProvider.getCognitoTokens().get()

From Xcode console i noticed this log:

Error when loading amplify credentials: KeychainStoreError: Error occurred while decoding AWSCredentials
Recovery suggestion: This should not happen. There is a possibility that there is a bug if this error persists. Please take a look at https://github.com/aws-amplify/amplify-ios/issues to see if there are any existing issues that match your scenario, and file an issue with the details of the bug if there isn't.
Issue encountered at:
file: /Users/user/Library/Developer/Xcode/DerivedData/xxxxx/SourcePackages/checkouts/amplify-swift/AmplifyPlugins/Core/AWSPluginsCore/Keychain/KeychainStoreError.swift
function: recoverySuggestion
line: 90
Caused by:

typeMismatch(Swift.Dictionary<Swift.String, Any>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "userPoolOnly", intValue: nil), UserPoolOnlyCodingKeys(stringValue: "signedInData", intValue: nil), CodingKeys(stringValue: "signInMethod", intValue: nil), CodingKeys(stringValue: "apiBased", intValue: nil), ApiBasedCodingKeys(stringValue: "_0", intValue: nil)], debugDescription: "Expected to decode Dictionary<String, Any> but found a string instead.", underlyingError: nil))

Steps To Reproduce

Steps to reproduce the behavior:
1. Start the app with the updated version of Amplify Swift (2.45.1)
2. Request the token via `cognitoTokenProvider.getCognitoTokens().get()`
3. Got the error

Expected behavior

A valid access token should be returned

Amplify Framework Version

2.45.1

Amplify Categories

Auth

Dependency manager

Swift PM

Swift version

5.10

CLI version

12.12.6

Xcode version

Xcode 16.1 Build version 16B40

Relevant log output

<details>
<summary>Log Messages</summary>


INSERT LOG MESSAGES HERE
```

Is this a regression?

No

Regression additional context

No response

Platforms

No response

OS Version

18.1

Device

Simulator and real device (iPhone 15)

Specific to simulators

NO

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions