Error: Property "todoListId" cannot be changed (using todo-list example) - loopbackjs

I have clone the example "todo-list" from github and without modifying anything the #post todo-lists is created without. then I use the responsed "Id" to #post /todo-lists/{id}/todos and it gave error
Unhandled error in POST /todo-lists/3/todos: 500 Error: Property "todoListId" cannot be changed!
at Object.constrainDataObject (D:\Projects\NodeJs\lbex\loopback4-example-todo-list\node_modules#loopback\repository\dist\repositor
ies\constraint-utils.js:49:19)
at DefaultHasManyRepository.create (D:\Projects\NodeJs\lbex\loopback4-example-todo-list\node_modules#loopback\repository\dist\rela
tions\has-many\has-many.repository.js:21:59)
at process._tickCallback (internal/process/next_tick.js:68:7)
I also tried to create everything by myself following the example.
https://loopback.io/doc/en/lb4/HasMany-relation.html
It sill give the same error.
PS. I have posted this on the loopback github but I don't know if that's the right place to post. So, I posted it here instead.

You must be sending todoListId in the request body. Remove that. Loopback juggler automatically attaches that value upon saving.
Below request body worked for me.
{
"title": "Testing 123",
"desc": "This is a testing description",
"isComplete": true
}

Related

Cannot Read Context in Dialogflow Fulfillment (Suddenly Undefined)

We built a Dialogflow agent using google cloud functions as webhook which worked properly until yesterday evening. At that time I exported the agent and reimported it later on and it worked for a while.
What stopped working is that agent.context.get('...'); (also agent.getContext('...')) does return undefined even if the context is set according to the UI and raw API response.
As an example I have an intent which has a required slot shop, webhook for slot filling enabled.
When I test the agent, the intent named info is matched correctly and also the context info_dialog_params_store seems to be there:
And here is part of the output context according to the raw API response:
"outputContexts": [
{
"name": "projects/MYAGENTNAME/agent/sessions/0b753e8e-b377-587b-3db6-3c8dc898879b/contexts/info_dialog_params_store",
"lifespanCount": 1,
"parameters": {
"store": "",
"store.original": "",
"kpi": "counts",
"date_or_period": "",
"kpi.original": "trafico",
"date_or_period.original": ""
}
}
In the webhook I mapped the intent correctly to a js function:
let intentMap = new Map();
intentMap.set('info', info);
agent.handleRequest(intentMap);
And the first line of the info function looks like:
function info(agent) {
store_context = agent.context.get('info_dialog_params_store');
}
Which returns
TypeError: Cannot read property 'get' of undefined
at info (/user_code/index.js:207:36)
at WebhookClient.handleRequest (/user_code/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:303:44)
at exports.dialogflowFirebaseFulfillment.functions.https.onRequest (/user_code/index.js:382:9)
at cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:57:9)
at /var/tmp/worker/worker.js:762:7
at /var/tmp/worker/worker.js:745:11
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
I am quite sure that I did not change anything which could affect the proper functioning of agent, except some refactoring.
I also tried the beta functions activated as well as deactivated as I read that there can be issues with environments, but that did not change anything.
Anyone knows in which direction I can investigate further?
I had the same issue, I resolved it updating dialogflow-fulfillment in package.json:
from "dialogflow-fulfillment": "^0.5.0"
to "dialogflow-fulfillment": "^0.6.0"
I solved the problem by turning off "Beta features"
enter image description here
Actually I could fix it by the following 'magic' steps:
Copied my original function to a text file
Copy and pasted the original example code into the GUI fulfillment code editor (Code on GitHub)
Deployed the function
Created a minimal example for my info function:
function info(agent) {
store_context = agent.context.get('info_dialog_params_store');
}
Tested it, and it worked
Copied back my original code
Everything was fine again

Unrecognized Verify Auth Challenge Lambda response C#

Hy, I'm implementing a custom auth flow on a Cognito User Pool. I managed to handle the Define- and CreateAuthChallenge-triggers, but not the VerifyAuthChallenge.
I use this documentation as a guide: Verify Auth Challenge Response Lambda Trigger
I take the verify-lambda input and add answerCorrect = true to the response, as described in the documentation. Define- and CreateChallenge-parts work as expected with the given information. Verifying the challenge answers, I get InvalidLambdaResponseException: Unrecognizable lambda output as a response. The verify-lambda exists successfully, returning this object:
{
"version": 1,
"triggerSource": "VerifyAuthChallengeResponse_Authentication",
"region": "eu-central-1",
"userPoolId": "eu-central-1_XXXXXXXXX",
"callerContext": {
"awsSdkVersion": "aws-sdk-dotnet-coreclr-3.3.12.7",
"clientId": "2490gqsa3gXXXXXXXXXXXXXXXX"
},
"request": {
"challengeAnswer": "{\"DeviceSub\":\"TestSub\"}",
"privateChallengeParameters": {
"CUSTOM_CHALLENGE": "SessionService_SendDevice"
},
"userAttributes": {
"sub": "8624237e-0be8-425e-a2cb-XXXXXXXXXXXX",
"email_verified": "true",
"cognito:user_status": "CONFIRMED",
"email": "X.XXXXXXXX#XXXXXXXXXX.de"
}
},
"response": {
"answerCorrect": true
},
"userName": "8624237e-0be8-425e-a2cb-XXXXXXXXXXXX"
}
Before, I ran into the problem, that the "challengeAnswer"-part was described as a Dictionary in the documentation, but it actually is just a string, containing the dictionary as json. Sadly, I cannot find any information anywhere for why the returned object isn't accepted by Cognito.
Apparently someone had the same problem as me, using JavaScript: GitHub link
Can anyone tell me, what the response object should look like, so that it is accepted by Cognito? Thank you.
Well, so my mistake was to not consider the custom authentication flow. I found a different documentation, which is by the way the one you should definitely use:
Customizing your user pool authentication flow
I ran into 2 wrong parts in the documentation here (the triggers sub-pages) and 1 error on my part.
Wrong part 1:
DefineAuthChallenge and CreateAuthChallenge inputs for the session is defined as a list of challenge results. This is all fine, but the challenge result object has the challenge metadata part wrongly displayed of being written like this: "ChallengeMetaData", when instead it should be "ChallengeMetadata", with a lower case "d" for "data" instead of an upper case one. This gave me the "Unrecognized lambda output"-error, because "ChallengeMetaData" wasn't what the backend was expecting, it was looking for "ChallengeMetadata", which wasn't present. The first time you enter the define auth challenge lambda, this error doesn't show up, because the session doesn't contain any challenge answers. The moment you verify a challenge though, this gets filled and then the uppercase d gives you troubles.
Wrong part 2:
As described in my question, the VerifyAuthChallenge input for the "challengeAnswer" is a string, not a Dictionary.
All these wrong parts are correctly displayed on the first documentation page I linked here. So I would recommend using that instead of the other documentation.
Error on my side:
I didn't really check what happens after you verify a custom challenge via the VerifyAuthChallenge-trigger. In the given link, in the image above the headline 'DefineAuthChallenge: The challenges (state machine) Lambda trigger', it clearly states, that after verifying the response, the DefineAuthChallenge trigger is invoked again, which I didn't consider.
I hope I could save someone the time it took for me to figure this out with this :-)

How to send a post request with parameter?

I created a WebAPI with Visual Studio 2017 using its .Net Core template. I am able to test my Get() code with Postman and everything works correctly. Now, I would like to send a Post request so it calls the following code.
[HttpPost]
public void Post([FromBody] string value)
{
Console.WriteLine("value" + value);
}
However, I get the following error when call
https://localhost:44364/api/carbon?value=100
{
"": [
"A non-empty request body is required."
]
}
I am sure the problem lies with they way my Postman is setup but it looks correct.
Any suggestions? Thank you!
Updated per suggestion
I added key/value to the body and received "The input was not valid."
You do not need to use Query string.You need to post the string with raw json, and do not forget the double quotation marks.Refer to here to get more details on post methods by Postman.
The error message you're receiving is very descriptive of the problem - you haven't provided a body in your request.
Click "Body" in Postman (next to "Headers") then select the type of body you want to send, for example x-www-form-urlencoded and then add a key/value pair beneath, e.g. test and hello world.
Hit "Send".

How to handle a 400 error with Ember Data (2.4.0-canary)

I can't figure out if my problem has to do with my query or my response or something else.
In my route I'm using a queryRecord:
model(params) {
return this.store.queryRecord('invitation', {
'invitation_token' : params.invitationToken
});
},
I'm properly receiving on the server side but I'm testing the case where the invitation token no longer exists. Therefore, the server is returning a 400 with a json payload which has an explanation of the error.
{"error":"Error finding invitation"}
But back on the ember side I'm just getting two errors (really it is just one).
Error while processing route: accept-invitation Ember Data Request GET /api/users/invitation returned a 400
Error: Ember Data Request GET /api/users/invitation returned a 400
It used to be (under Ember 2.2.1):
Error while processing route: accept-invitation Adapter operation failed Error: Adapter operation failed
Error: Adapter operation failed
What am I supposed to be returning from the server in the case that the token wasn't found? These messages makes it looks like something unexpected happen within Ember.
I'd assume that a 400 would tell Ember that there was an error, and it would go to the error state for the route. But instead it goes to the error state at the application level and spits out these error messages in the log.
I'm expecting the server to return a 400, so I'm not sure why Ember is complaining. What should I be returning and how should I properly handle this?
I believe that your application should be returning a response that is formatted differently. As per the JSON API specification,
Error objects MUST be returned as an array keyed by errors in the top
level of a JSON API document.
The specification also specifies that the following members, among others, may be provided (see the link for the full list).
title: a short, human-readable summary of the problem that SHOULD NOT
change from occurrence to occurrence of the problem, except for
purposes of localization.
detail: a human-readable explanation
specific to this occurrence of the problem. Like title, this field's
value can be localized
status: the HTTP status code applicable to this problem, expressed as
a string value.
If you try returning something along the lines of what is below, how does the tooling behave?
{
"errors": [
{
"status": "400",
"title": "Error finding invitation"
}
]
}

Facebook Comment widget returns "Content no longer available"

Following the upgrade from Graph 1.0 to Graph 2.0 the comment widgets have stopped working for me, returning the following JSON response following any attempt to post a comment:
{
bootloadable: {}
error: 1357031
errorDescription: "The content you requested cannot be displayed right now. It may be temporarily unavailable, the link you clicked on may have expired, or you may not have permission to view this page."
errorSummary: "This content is no longer available"
ixData: {}
lid: "0"
payload: null
}
I've been through the steps so far of regenerating the comment code, making sure the comment block code itself is set to use version 2.3 (as well as trying without this just to be safe). The error code itself doesn't return anything in the FB docs, and the only reference I can find to the error description is from 2 years ago to which FB noted that it was a server issue. Given that our comments have been broken (and thus hidden) for 2 months now I don't think that's the problem.
I've confirmed that the code pulls in sdk.js rather than all.js using the code they provide and I just can't seem to get it to work. Any help would be appreciated!
Have you have tried to re-upload these files?
admin.css
class-admin.php
class-fronted.php
facebook-comments.php