Skip to content
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

Support for not passing in value for Optional Embedded Collection of Strings #541

Closed
lawmicha opened this issue Jun 12, 2020 · 4 comments
Closed
Assignees
Labels
api Issues related to the API category bug Something isn't working datastore Issues related to the DataStore category

Comments

@lawmicha
Copy link
Contributor

Describe the bug
API request is failing when not specifying a value for an optional embedded collection of strings

To Reproduce
Steps to reproduce the behavior:

  1. schema
type Todo @model {
  id: ID!
  stickies: [String]
}
  1. Create a Todo without any stickies, it will default to empty array [].
  2. Make API call, it will create the query variables
{
  "input" : {
    "stickies" : [

    ],
    "id" : "65883374-7B84-4457-81CD-FE1314173F44"
  }
}
  1. See error
{
  "data": {
    "createTodo": null
  },
  "errors": [
    {
      "path": [
        "createTodo"
      ],
      "data": null,
      "errorType": "DynamoDB:DynamoDbException",
      "errorInfo": null,
      "locations": [
        {
          "line": 2,
          "column": 3,
          "sourceName": null
        }
      ],
      "message": "Supplied AttributeValue is empty, must contain exactly one of the supported datatypes (Service: DynamoDb, Status Code: 400, Request ID: HQVD25FPEVRHJQMBCCSTO6TFFVVV4KQNSO5AEMVJF66Q9ASUAAJG)"
    }
  ]
}

Expected behavior
When there is an empty array, we should just remove it from the variables. this may be a regression for this change? #519

@lawmicha lawmicha changed the title Support for Optional Embedded Collection of Strings Support for not passing in value for Optional Embedded Collection of Strings Jun 12, 2020
@lawmicha lawmicha added api Issues related to the API category bug Something isn't working datastore Issues related to the DataStore category labels Jun 12, 2020
@lawmicha
Copy link
Contributor Author

codegen changes were released in 4.21.4 but deprecated, to reproduce for now, use
npm install -g @aws-amplify/cli@iosCodegenWorkshop
or use latest master branch of CLI

@ruiguoamz ruiguoamz reopened this Jun 24, 2020
@ruiguoamz
Copy link
Contributor

Using

  • embedded type
  • CLI (4.21.4)
    the issue doesn't occur anymore.

This is how todo object (without stickies) got created based on the schema from above link
let todo = Todo(id: "1234", name: "name", description: "description", categories: [Category(name: "Category", color: Color(name: "red", red: 255, green: 0, blue: 0))], section: Section(name: "section", number: 1.0))

@lawmicha
Copy link
Contributor Author

this was reproduced here #595

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the API category bug Something isn't working datastore Issues related to the DataStore category
Projects
None yet
Development

No branches or pull requests

2 participants