Skip to content

Error setting field-level authorization #3320

@kouz75

Description

@kouz75

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

22.x

Amplify CLI Version

14.0.0

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Describe the bug

Hi,

I'm trying to set field-level authorization on this table:

type DeviceToken @model(subscriptions:null)
@auth(rules: [
{ allow: owner, ownerField: "usersub"}
])
{
id: ID!
@PrimaryKey
@auth(rules: [{ allow: owner, operations: [read,delete] }])
usersub: String
@index(name: "byUser", queryField: "deviceTokensByUser")
@auth(rules: [{ allow: owner, operations: [read,delete] }])
platform: String
token: String
appVersion: String
}

during push, I got the error
🛑 When using field-level authorization rules you need to add rules to all of the model's required fields with at least read permissions. Found model "DeviceToken" with required fields ["id"] missing field-level authorization rules.

I already have an @auth directive on the id field, so I'm not sure why it's being flagged as missing. Is there an issue with how the authorization rule is applied on the id field?

Thanks for your help.

Expected behavior

field-level authorization should be publish

Reproduction steps

add the model in your schema and push it

Project Identifier

Project Identifier: ed57bb8a46476511162afa8497d78147

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

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