question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get type mismatch when using array of dynamic groups in @auth rules

See original GitHub issue

I am trying to use an array of dynamic groups in the @auth rules and I get type mismatch error. It works in the mock just fine though. It also works if I use a single group instead of an array. Here are my schema and the error message that I am getting.

type ViralLoad
@model
@key(
  name: "ByDate"
  fields: ["groups", "createdAt"]
  queryField: "viralLoadByGroup"
)
@auth(
  rules: [
    { allow: owner }
    { allow: groups, groupsField: "groups", operations: [read] }
  ]
) {
  id: ID!
  location: String!
  createdAt: AWSDateTime
  time: [ViralLoadTime]
  reagentKitID: String
  machineID: String
  samples: [ViralSample]
  groups: [String]
}

type ViralLoadTime {
  start: AWSDateTime
  stop: AWSDateTime
  experimental: AWSDateTime
}

type ViralSample {
  load: Int
  control: Int
}

My sample mutation.

mutation MyMutation {
  createViralLoad(input: {location: "Location 1", createdAt: "2020-09-09T00:00:00Z", groups: ["Admin"]}) {
    location
    createdAt
  }
}

And the error message.

{
  "data": {
    "createViralLoad": null
  },
  "errors": [
    {
      "path": [
        "createViralLoad"
      ],
      "data": null,
      "errorType": "DynamoDB:DynamoDbException",
      "errorInfo": null,
      "locations": [
        {
          "line": 2,
          "column": 3,
          "sourceName": null
        }
      ],
      "message": "One or more parameter values were invalid: Type mismatch for Index Key groups Expected: S Actual: L IndexName: ByDate (Service: DynamoDb, Status Code: 400, Request ID: QRGBTDVJ7EDIJV0JBK4JCJCDHRVV4KQNSO5AEMVJF66Q9ASUAAJG, Extended Request ID: null)"
    }
  ]
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
RossWilliamscommented, Sep 11, 2020

The problem is even earlier. There is a bug in the @key transformer code that validates the schema. It incorrectly tests for scalar types. It calls a method to get the field type, but that method looks inside lists and reports on the type of the list, so it never detects an invalid list type. See here

0reactions
github-actions[bot]commented, May 25, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type mismatch on an Array assignment in ASP - Stack Overflow
Alternately If I setup questions as a dynamic array then the assignment fails with a type mismatch error. Class Survey public ID public...
Read more >
LLVM Language Reference Manual
Abstract¶. This document is a reference manual for the LLVM assembly language. LLVM is a Static Single Assignment (SSA) based representation that provides ......
Read more >
Firebase Cloud Messaging HTTP protocol - Google
Emulator Suite Security Rules Unit Testing Library. Overview · HostAndPort · RulesTestContext · RulesTestEnvironment · TestEnvironmentConfig. iOS — Swift.
Read more >
NSX API Guide 6.4 - VMware Docs
Configuring REST Clients for the NSX REST API. Some common REST clients include Postman, RESTClient (a Firefox add-on), and curl (a command-line tool)....
Read more >
SQL Error Messages | InterSystems IRIS Data Platform 2022.2
-19, An aggregate function cannot be used in a WHERE or GROUP BY clause. -20, Name conflict in the FROM ... -193, Model...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found