Skip to content

fix(core): Set userAgent when using AmplifyOutputs to configure#3215

Merged
mattcreaser merged 4 commits into
mainfrom
mattcreaser/user-agent-gen2
Feb 27, 2026
Merged

fix(core): Set userAgent when using AmplifyOutputs to configure#3215
mattcreaser merged 4 commits into
mainfrom
mattcreaser/user-agent-gen2

Conversation

@mattcreaser
Copy link
Copy Markdown
Member

  • PR title and description conform to Pull Request guidelines.

Issue #, if available:

Description of changes:
The user agent is now configured when Amplify is using a Gen2 config.

How did you test these changes?

Documentation update required?

  • No
  • Yes (Please include a PR link for the documentation update)

General Checklist

  • Added Unit Tests
  • Added Integration Tests
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
  • Ensure commit message has the appropriate scope (e.g fix(storage): message, feat(auth): message, chore(all): message)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mattcreaser mattcreaser requested a review from a team as a code owner February 27, 2026 15:42
jvh-aws
jvh-aws previously approved these changes Feb 27, 2026
@mattcreaser mattcreaser enabled auto-merge (squash) February 27, 2026 15:54
@mattcreaser mattcreaser disabled auto-merge February 27, 2026 16:19
@mattcreaser
Copy link
Copy Markdown
Member Author

mattcreaser commented Feb 27, 2026

https://github.com/aws-amplify/amplify-flutter/blob/1532f8419e0765ef290ecec484ea7c2ec4af5702/packages/amplify_datastore/android/src/main/kotlin/com/amazonaws/amplify/amplify_datastore/AmplifyDataStorePlugin.kt#L950 this will cause issues with this PR

This is because flutter first calls Amplify.addUserAgentPlatform which calls UserAgent.configure. Flutter then calls Amplify.configure which, after this PR, also calls UserAgent.configure. UserAgent.configure throws an exception if it's called multiple times.

As a workaround I removed the exception that's thrown if the user agent is configured multiple times, instead just silently failing on subsequent configures. This preserves the existing Flutter behaviour and allows the user agent to be set from Amplify.configure. To help customers avoid calling this method I'll annotate it with AmplifyInternalWarning.

@mattcreaser mattcreaser force-pushed the mattcreaser/user-agent-gen2 branch from 0af117f to ad15bff Compare February 27, 2026 16:36
@mattcreaser mattcreaser requested a review from a team as a code owner February 27, 2026 16:36
@mattcreaser mattcreaser enabled auto-merge (squash) February 27, 2026 17:54
@mattcreaser mattcreaser merged commit 7971c8b into main Feb 27, 2026
14 of 15 checks passed
@mattcreaser mattcreaser deleted the mattcreaser/user-agent-gen2 branch February 27, 2026 18:00
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.

3 participants