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.

[BUG] ValidationException: The provided key element does not match the schema

See original GitHub issue

Summary:

Model.get throw the error below when it gets an item from the table with string partition key.

Code sample:

var dynamoose = require('dynamoose');
const User = dynamoose.model("User", {"id": String, "name": String});
  try {
    const myUser = await User.get('1');
    console.log(myUser);
  } catch (error) {
    console.error(error);
  }

Schema

{"id": String, "name": String}

Model

// Code here

General

// Code here

Current output and behavior (including stack trace):

Expected output and behavior:

Getting the document without an error

Environment:

Operating System: masOS Big Sur Operating System Version: 11.4 Node.js version (node -v): 16.13.1 NPM version: (npm -v): 8.1.2 Dynamoose version: 2.8.5

Other information (if applicable):

Other:

  • I have read through the Dynamoose documentation before posting this issue
  • I have searched through the GitHub issues (including closed issues) and pull requests to ensure this issue has not already been raised before
  • I have searched the internet and Stack Overflow to ensure this issue hasn’t been raised or answered before
  • I have tested the code provided and am confident it doesn’t work as intended
  • I have filled out all fields above
  • I am running the latest version of Dynamoose

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fishcharliecommented, Jun 12, 2022

@donghoon-song Sorry. Have to close this issue. You haven’t provided enough information for us to reproduce. As @andrewda said, this error is coming from AWS, not Dynamoose. My guess is the key doesn’t match what you have setup in AWS. But as I said, you haven’t provided enough information for us to be able to reproduce.

0reactions
donghoon-songcommented, Jun 5, 2022
const AWS = require('aws-sdk')
var documentClient = new AWS.DynamoDB();
try {
    const User = dynamoose.model("User", {"id": String, "name": String});
    const myUser = await User.get({id:'1'},{return:'request'});
    documentClient.getItem({Key:{id:{S:'1'}},TableName:'User'}).promise().then(console.log).catch(console.error)
    console.log(myUser);
  } catch (error) {
    console.error(error);
  }

image

The returned request is the same as you described. But it still throws the error in the screenshot. Thank you ☺️

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValidationException: The provided key element does not ...
DocumentClient() I kept getting "ValidationException: The provided key element does not match the schema" without it telling me what was wrong.
Read more >
[Solved] DynamoDB Key element does not match the schema
When performing a put or update operation, it is likely that you are trying to insert a record which does not have all...
Read more >
The Provided Key Element Does Not Match the Schema Error
The provided key element does not match the schema error occurs due to only half of the primary key provided for an item...
Read more >
DynamoDB The provided key element does not ... - Edureka
user = users.get_item(email='john.doe@gmail.com'). I get the following error : 'The provided key element does not match the schema'.
Read more >
Resolve error "The provided key element does not match the ...
Resolution. This error usually happens when you have an incorrect schema, corrupt data, or mismatched data. If you still get the error message ......
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