-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gen 2 Client Update fails (Cannot destructure property 'isReadOnly' of 'fields[fieldName]' as it is undefined) #3059
Comments
Hi @MKlaeui thanks for raising this issue! 👋 This is probably a configuration related issue. I see that you are calling Can you share what the config looks like? There should be a model introspection schema in it. Also, please confirm that the sandbox is running and updating the |
@MKlaeui Thank you for the MIS! Unfortunately, there isn't anything that stands out about the MIS. const record = { ...sites[idx], name };
console.log({record}) // add this console log Lastly, could you also share how you're configuring the Amplify library? (ex. calling |
Attached is the log of the record. I'm not sure this will help, but I suspected it may have something to do with this being a Next App Router project, so I created it as a plain React/Vite project. However, I got a similar error, the only difference being that it said fields7[fieldname]. I'm also attaching that. Thanks! Calling Amplify.configure in Layout like so:
|
Hi @MKlaeui! So, I was able to reproduce the error with the given shape of the input object. It seems the Work AroundI was able to work around this by simply omitting the owner field from the input object: async function updateSite(idx: number) {
const name = window.prompt("Site name") ?? "You entered nothing.";
const { owner, ...siteWithoutOwner } = sites[idx];
const record = { ...siteWithoutOwner, name };
const conf = Amplify.getConfig();
console.log("Just before", { conf, record });
const { errors, data } = await client.models.Site.update(record);
if (data) {
console.log("The site update was successful: " + data.name);
} else if (errors) {
console.log("Errors occured while updating a site", errors);
}
} The schema does include owner auth on the If the Site: a
.model({
name: a.string().required(),
displayName: a.string().required(), // title
owner: a.string(),
}) I will mark this as a bug for the team to investigate further. In the meantime, I would recommend using the workaround until we decide how we want to address this behavior and release a fix. |
Thanks Chris, much appreciated! |
Environment information
Data packages
Description
I have an Next SSR project. Whenever I try to use the client update function, I get a type error (Cannot destructure property 'isReadOnly' of 'fields[fieldName]' as it is undefined.)
The text was updated successfully, but these errors were encountered: