You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When creating a new record using Cognito authentication in an Amplify project, the username field is being populated incorrectly. The username value appears duplicated in the format userID::userID instead of the expected single userID format. This is affecting our ability to query and manage records accurately, as the concatenated format does not match our expected schema.
It creates the record, but the response comes null for all the stuff that needs to relate to.
To Reproduce
Steps to reproduce the behavior:
Define a model in the schema with a field (e.g., username) marked with @auth rules that depend on owner and allow: owner with custom ownerField.
Use Cognito to create a new record for this model, ensuring that Cognito automatically populates the username.
async create(input: CreateLeagueInput) {
const { data } = await API.graphql(
graphqlOperation(createLeague, { input: { ...input } })
) as CreateLeagueResult;
if (!data) {
throw new Error('There was an issue trying to create a new league');
}
return data.createLeague;
}
Query or inspect the new record, observing that the username field contains a duplicated userID::userID instead of the expected single user ID.
You will get something like "244884a8-20c1-7099-7bab-b1e8c8eef5fb::244884a8-20c1-7099-7bab-b1e8c8eef5fb"
Expected behavior
The username field should only contain the user’s Cognito ID as a single value (e.g., userID), without any additional concatenation.
Desktop (please complete the following information):
OS: MacOS
Browser Chrome
Version 130
Additional context
The issue is occurring in an environment where we use Amplify's @auth directive with owner authorization. This unintended concatenation might be due to the IAM and Cognito configurations or a possible bug in the auto-population of owner fields by Amplify. Creating a lambda function to create the league through IAM in the backend works but is not a sustainable solution.
Besides, due to these issues, I am getting a lot of errors like below, which I am assuming is due of this issue with the double format username.
The text was updated successfully, but these errors were encountered:
Describe the bug
When creating a new record using Cognito authentication in an Amplify project, the username field is being populated incorrectly. The username value appears duplicated in the format userID::userID instead of the expected single userID format. This is affecting our ability to query and manage records accurately, as the concatenated format does not match our expected schema.
It creates the record, but the response comes null for all the stuff that needs to relate to.
To Reproduce
Steps to reproduce the behavior:
type League @model
@auth(
rules: [
{ allow: owner, ownerField: "username" },
{ allow: private, provider: iam }
]
)
{
id: ID!
clubID: ID! @index(name: "byClubLeague", queryField: "listLeaguesByClubId")
club: Club @belongsTo(fields: ["clubID"])
name: String!
tournaments: [Tournament] @hasmany(indexName: "byLeagueTournament", fields: ["id"])
username: String
}
async create(input: CreateLeagueInput) {
}
You will get something like "244884a8-20c1-7099-7bab-b1e8c8eef5fb::244884a8-20c1-7099-7bab-b1e8c8eef5fb"
Expected behavior
The username field should only contain the user’s Cognito ID as a single value (e.g., userID), without any additional concatenation.
Desktop (please complete the following information):
Additional context
The issue is occurring in an environment where we use Amplify's @auth directive with owner authorization. This unintended concatenation might be due to the IAM and Cognito configurations or a possible bug in the auto-population of owner fields by Amplify. Creating a lambda function to create the league through IAM in the backend works but is not a sustainable solution.
Besides, due to these issues, I am getting a lot of errors like below, which I am assuming is due of this issue with the double format username.
The text was updated successfully, but these errors were encountered: