Skip to content

fix(aws-amplify): partial configure drops non-Auth libraryOptions after Auth is already set up #14816

Description

@ShrutiPundir17

Before opening, please confirm:

JavaScript Framework

Next.js

Amplify APIs

Authentication, Storage

Amplify Version

v6

Amplify Categories

auth, storage

Backend

Amplify Gen 2

Environment information

Details
# Put output below this line

  System:
    OS: Windows 11 10.0.26200
    CPU: (8) x64 Intel(R) Core(TM) Ultra 7 256V
    Memory: 1.94 GB / 15.54 GB
  Binaries:
    Node: 22.17.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (140.0.3485.54)
  npmPackages:
    @babel/core: ^7.29.0 => 7.29.0 (7.28.4, 7.28.3, 7.28.0)
    @babel/preset-env: ^7.0.0 => 7.28.0
    @changesets/changelog-github: ^0.5.2 => 0.5.2
    @changesets/cli: ^2.27.1 => 2.29.8
    @eslint/compat: ^1.2.0 => 1.3.1
    @rollup/plugin-commonjs: ^28.0.1 => 28.0.6
    @rollup/plugin-typescript: ^11.1.6 => 11.1.6
    @size-limit/file: ^11.2.0 => 11.2.0
    @size-limit/webpack: ^11.2.0 => 11.2.0
    @size-limit/webpack-why: ^11.2.0 => 11.2.0
    @stylistic/eslint-plugin: ^2.8.0 => 2.13.0
    @types/jest: ^29.5.8 => 29.5.14
    @types/lodash: 4.14.182 => 4.14.182
    @types/node: ^8.9.5 => 8.10.66 (24.1.0, 12.20.55, 18.19.120)
    @typescript-eslint/eslint-plugin: ^8.8.1 => 8.38.0 (7.18.0)
    @typescript-eslint/parser: ^8.8.1 => 8.38.0 (7.18.0)
    babel-loader: ^8.3.0 => 8.4.1
    eslint: ^9.12.0 => 9.31.0
    eslint-config-prettier: ^9.1.0 => 9.1.2 (8.10.2)
    eslint-config-standard: ^17.1.0 => 17.1.0
    eslint-import-resolver-typescript: ^3.6.3 => 3.10.1
    eslint-plugin-import: ^2.31.0 => 2.32.0
    eslint-plugin-jsdoc: ^50.3.1 => 50.8.0
    eslint-plugin-n: ^17.10.3 => 17.21.0
    eslint-plugin-prettier: ^5.2.1 => 5.5.3
    eslint-plugin-promise: ^7.1.0 => 7.2.1
    eslint-plugin-unused-imports: ^4.1.4 => 4.1.4
    expect: ^29.7.0 => 29.7.0
    glob: ^10.3.10 => 10.5.0 (7.2.3, 9.3.5, 13.0.6)
    husky: ^9.0.11 => 9.1.7
    jest: ^29.7.0 => 29.7.0
    jest-environment-jsdom: ^29.7.0 => 29.7.0
    license-check-and-add: ^4.0.5 => 4.0.5
    lint-staged: ^15.2.2 => 15.5.2
    mkdirp: ^3.0.1 => 3.0.1 (1.0.4, 0.5.6)
    prettier: ^3.2.5 => 3.6.2 (2.8.8)
    rimraf: ^6.1.3 => 6.1.3 (3.0.2, 2.6.3)
    rollup: ^4.9.6 => 4.59.0
    size-limit: ^11.2.0 => 11.2.0
    ts-jest: ^29.1.1 => 29.4.0
    turbo: ^2.3.3 => 2.8.12
    typedoc: ^0.28.17 => 0.28.17
    typedoc-plugin-extras: ^4.0.0 => 4.0.1
    typedoc-plugin-missing-exports: ^2.2.0 => 2.3.0
    typescript: 5.8.3 => 5.8.3
    typescript-coverage-report: ^0.6.4 => 0.6.4
    uuid-validate: ^0.0.3 => 0.0.3
    webpack: ^5.75.0 => 5.105.4 (5.104.1)
    webpack-cli: ^5.0.0 => 5.1.4
  npmGlobalPackages:
    vercel: 50.1.0


Describe the bug

Describe the bug

When Amplify.configure from the aws-amplify package (DefaultAmplify.configure) runs after Auth has already been configured with default Cognito providers, a second call with partial libraryOptions (for example only { ssr: true }) can drop options that were only present on the previous singleton libraryOptions object (for example Storage).

@aws-amplify/core replaces libraryOptions whenever a new object is passed; the DefaultAmplify path for “Auth already configured + no new libraryOptions.Auth” previously built { Auth: authLibraryOptions, ...libraryOptions }, which did not carry forward keys omitted from the partial libraryOptions argument.

Expected behavior

Calling Amplify.configure again with partial libraryOptions should merge with existing Amplify.libraryOptions so category options such as Storage remain unless explicitly overridden or cleared.

Reproduction steps

  1. Configure with Auth and non-Auth libraryOptions (e.g. Storage) on the first Amplify.configure.
  2. Call Amplify.configure again with the same or updated resource config that still includes Auth, passing only a partial libraryOptions object (e.g. { ssr: true }).
  3. Observe that Storage (and similar keys) are no longer present on the singleton libraryOptions passed to core.

Code Snippet

// Pseudocode illustrating the scenario
Amplify.configure(configWithAuth, { Storage: { S3: { defaultAccessLevel: 'private' } } });
Amplify.configure(configWithAuth, { ssr: true });
// Storage should not be lost from libraryOptions

### Log output

<details>

// Put your logs below this line


</details>


### aws-exports.js

_No response_

### Manual configuration

_No response_

### Additional configuration

None required. Bug is in `packages/aws-amplify/src/initSingleton.ts` merge path when calling `@aws-amplify/core` `Amplify.configure` with partial `libraryOptions`.

### Mobile Device

Not applicable (web / Node SSR).

### Mobile Operating System

_No response_

### Mobile Browser

_No response_

### Mobile Browser Version

_No response_

### Additional information and screenshots

**Pull request (fix + regression test + changeset):**  
https://github.com/aws-amplify/amplify-js/pull/14815

**Summary of fix:**  
Merge `...Amplify.libraryOptions`, then `...libraryOptions`, then `Auth: authLibraryOptions` before calling core `Amplify.configure`.

**Tests:**  
`packages/aws-amplify/__tests__/initSingleton.test.ts` — new case: Storage pre-seeded, then partial `{ ssr: true }`; asserts Storage + ssr + Auth forwarded.

Screenshots not applicable (library behavior, no UI).

Metadata

Metadata

Assignees

No one assigned

    Labels

    AuthRelated to Auth components/categoryStorageRelated to Storage components/categorybugSomething isn't workingpending-maintainer-responseIssue is pending a response from the Amplify team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions