Alexa fails to send skill request after connecting to MongoDb - mongodb

I have a strange thing going on in my Alexa skill. My skill requires to connect with MongoDB and save data. Whenever I connect to database, Alexa is giving me this response: "There was a problem with the requested skill's response". It is completely weired because few days ago my database and Alexa skill were perfectly working. Now, suddenly, I don't get any response from Alexa even though my database in connected and creats documents.
Below is my JSON INPUT and code from the Launchrequesthandler :
{
"version": "1.0",
"session": {
"new": true,
"sessionId": "amzn1.echo-api.session.b163d6da-ab3d-483c-ba19-60156810739c",
"application": {
"applicationId": "amzn1.ask.skill.bd7f1ea6-53ab-41af-9a59-4853d4906373"
},
"user": {
"userId": "amzn1.ask.account.AFMYVNKRB3REUKGDDLGIFOYXR53ISFLYHQJXHO2YDRYVQCPCRLYQFIVLBE5HDXH6FNMTMN4YLXHR6ZMSJEFQ3Y2BRI76N2FHSHDXAWUPVFB6JKWSRTPA7EWOH6ZOF24KY5DXUBA3UMUY3TNQZ42AOOFESTFWW6VLTU63AHHQMMPKA74M2WX66TN4IYOZUNLMBXMX3LCUBWPO4FY"
}
},
"context": {
"Viewports": [
{
"type": "APL",
"id": "main",
"shape": "RECTANGLE",
"dpi": 213,
"presentationType": "STANDARD",
"canRotate": false,
"configuration": {
"current": {
"mode": "HUB",
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
},
"size": {
"type": "DISCRETE",
"pixelWidth": 1280,
"pixelHeight": 800
}
}
}
}
],
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 346,
"arcMinuteHeight": 216,
"canRotate": false,
"canResize": false
}
],
"mode": "HUB",
"shape": "RECTANGLE",
"pixelWidth": 1280,
"pixelHeight": 800,
"dpi": 213,
"currentPixelWidth": 1280,
"currentPixelHeight": 800,
"touch": [
"SINGLE"
],
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
}
},
"Extensions": {
"available": {
"aplext:backstack:10": {}
}
},
"System": {
"application": {
"applicationId": "amzn1.ask.skill.bd7f1ea6-53ab-41af-9a59-4853d4906373"
},
"user": {
"userId": "amzn1.ask.account.AFMYVNKRB3REUKGDDLGIFOYXR53ISFLYHQJXHO2YDRYVQCPCRLYQFIVLBE5HDXH6FNMTMN4YLXHR6ZMSJEFQ3Y2BRI76N2FHSHDXAWUPVFB6JKWSRTPA7EWOH6ZOF24KY5DXUBA3UMUY3TNQZ42AOOFESTFWW6VLTU63AHHQMMPKA74M2WX66TN4IYOZUNLMBXMX3LCUBWPO4FY"
},
"device": {
"deviceId": "amzn1.ask.device.AHVUJSCJ4KXLFF5SOTIFUCLYUXGBZFLUK3QURQHGX5S7N5E53K7O3ZXEO5V7KFPDR6XPPZECKTX5HEWB3BTLGAM34J7DVPKOALFNNDXCYDUIQWHNH327H3LCV3RNS7XFQLMJ6FXZ36JB5SF3YRUAEULDNIQCBSGZPR7J7KPCGCAHLPJXV5YRA",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.amazonalexa.com",
"apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLmJkN2YxZWE2LTUzYWItNDFhZi05YTU5LTQ4NTNkNDkwNjM3MyIsImV4cCI6MTYyNjY2MDY3NCwiaWF0IjoxNjI2NjYwMzc0LCJuYmYiOjE2MjY2NjAzNzQsInByaXZhdGVDbGFpbXMiOnsiY29udGV4dCI6IkFBQUFBQUFBQUFDWFBEU1FPNldCNURRZG9RaCtXRHZjS2dFQUFBQUFBQUFJVkx0RDV3L1VSTklPK1VEQkVGZWdDUTA2Z3IvZ1dRZHFCUThYSzBjSmZmQUhDRXRsR05QUDNEeXRVVjcyc1VFbWFHMktETjc1MkpMemNPNDhpdm1WYlFjbEMrZ1VrUU9BY09RUEw3R1JEVGd5SUpPVStoVkRNQ1BJdmJhd2F1YUUxM2wzcE95WmFlVDdocnA0dDF6bXJ6MkdyM1BJbXdB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xGSAD87kOW8ZiLY2n68IfiKTsUHf6Bp4YiLOMcWWErSTCq91JeYeau0W7B5TvZGTm04OmfK-qkZBVPq6ME8_ulukdZUNxIpVUItkSEuhppcegUcGkzqYdrPRY0BJrsBe-Pytu5xLRiBM3T78nTysnGM288IJSccGJ4rmW4UdzHA_lnH7543QhgU9t71JRncgEDKEsEcVgxs5biFR9il4W8ASfwuDeJhdy8HpiXZw"
}
},
"request": {
"type": "LaunchRequest",
"requestId": "amzn1.echo-api.request.3e29f996-69b2-4e90-bfef-628d74f57307",
"locale": "en-US",
"timestamp": "2021-07-19T02:06:14Z",
"shouldLinkResultBeReturned": false
}
}
//database connection//
const q="mongodb+srv://sumya:sumya123#mydata.acxs0.mongodb.net/Mydata?retryWrites=true&w=majority";
mongoose.connect(q,{ useNewUrlParser: true, useUnifiedTopology: true,useFindAndModify: false })
.then(() => console.log("Database connected!")
)
.catch(err => console.log(err))
const Alexa = require('ask-sdk-core');
const LaunchRequestHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
},
async handle(handlerInput) {
const speakOutput = 'Hi, I am Nao. I am here to give you counseling on your anxiety issues. Can I have your name, please? Note: We are not professional therapists or counselors. ';
const useri=handlerInput.requestEnvelope.session.user.userID;
const z=handlerInput.requestEnvelope.session.sessionId;
const g=Alexa.getUserId(handlerInput.requestEnvelope);
const curr_session=new post.session({
alexa_sessionid:z
});
let user=await post.findOne({userID:g});
if(!user){
user=new post({
userID:g
});
}
user.session_list.push(curr_session);
user.save();
return handlerInput.responseBuilder
.speak(speakOutput)
.reprompt(speakOutput)
.getResponse();
}
};
Here is the Log that I got from Cloudwatch.
START RequestId: 6a416b77-5d2c-4ebe-8ac4-dec09f67e9b9 Version: 304
2021-07-19T16:40:00.570Z 6a416b77-5d2c-4ebe-8ac4-dec09f67e9b9 INFO Database connected!
END RequestId: 6a416b77-5d2c-4ebe-8ac4-dec09f67e9b9
REPORT RequestId: 6a416b77-5d2c-4ebe-8ac4-dec09f67e9b9 Duration: 8008.11 ms Billed Duration: 8000 ms Memory Size: 512 MB Max Memory Used: 102 MB Init Duration: 653.49 ms
2021-07-19T16:40:08.023Z 6a416b77-5d2c-4ebe-8ac4-dec09f67e9b9 Task timed out after 8.01 seconds
START RequestId: 4e671447-8207-414e-aaf4-9a807fe3ac01 Version: 304
2021-07-19T16:40:08.894Z 4e671447-8207-414e-aaf4-9a807fe3ac01 INFO ~~~~ Session ended:
{
"version": "1.0",
"session": {
"new": false,
"sessionId": "amzn1.echo-api.session.05ca6843-cdc8-47eb-9a5f-081942cf2674",
"application": {
"applicationId": "amzn1.ask.skill.bd7f1ea6-53ab-41af-9a59-4853d4906373"
},
"user": {
"userId": "amzn1.ask.account.AFMYVNKRB3REUKGDDLGIFOYXR53ISFLYHQJXHO2YDRYVQCPCRLYQFIVLBE5HDXH6FNMTMN4YLXHR6ZMSJEFQ3Y2BRI76N2FHSHDXAWUPVFB6JKWSRTPA7EWOH6ZOF24KY5DXUBA3UMUY3TNQZ42AOOFESTFWW6VLTU63AHHQMMPKA74M2WX66TN4IYOZUNLMBXMX3LCUBWPO4FY"
}
},
"context": {
"Viewports": [
{
"type": "APL",
"id": "main",
"shape": "RECTANGLE",
"dpi": 213,
"presentationType": "STANDARD",
"canRotate": false,
"configuration": {
"current": {
"mode": "HUB",
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
},
"size": {
"type": "DISCRETE",
"pixelWidth": 1280,
"pixelHeight": 800
}
}
}
}
],
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 346,
"arcMinuteHeight": 216,
"canRotate": false,
"canResize": false
}
],
"mode": "HUB",
"shape": "RECTANGLE",
"pixelWidth": 1280,
"pixelHeight": 800,
"dpi": 213,
"currentPixelWidth": 1280,
"currentPixelHeight": 800,
"touch": [
"SINGLE"
],
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
}
},
"Extensions": {
"available": {
"aplext:backstack:10": {}
}
},
"System": {
"application": {
"applicationId": "amzn1.ask.skill.bd7f1ea6-53ab-41af-9a59-4853d4906373"
},
"user": {
"userId": "amzn1.ask.account.AFMYVNKRB3REUKGDDLGIFOYXR53ISFLYHQJXHO2YDRYVQCPCRLYQFIVLBE5HDXH6FNMTMN4YLXHR6ZMSJEFQ3Y2BRI76N2FHSHDXAWUPVFB6JKWSRTPA7EWOH6ZOF24KY5DXUBA3UMUY3TNQZ42AOOFESTFWW6VLTU63AHHQMMPKA74M2WX66TN4IYOZUNLMBXMX3LCUBWPO4FY"
},
"device": {
"deviceId": "amzn1.ask.device.AHVUJSCJ4KXLFF5SOTIFUCLYUXGBZFLUK3QURQHGX5S7N5E53K7O3ZXEO5V7KFPDR6XPPZECKTX5HEWB3BTLGAM34J7DVPKOALFNNDXCYDUIQWHNH327H3LCV3RNS7XFQLMJ6FXZ36JB5SF3YRUAEULDNIQCBSGZPR7J7KPCGCAHLPJXV5YRA",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.amazonalexa.com",
"apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJhdWQiOiJodHRwczovL2FwaS5hbWF6b25hbGV4YS5jb20iLCJpc3MiOiJBbGV4YVNraWxsS2l0Iiwic3ViIjoiYW16bjEuYXNrLnNraWxsLmJkN2YxZWE2LTUzYWItNDFhZi05YTU5LTQ4NTNkNDkwNjM3MyIsImV4cCI6MTYyNjcxMzA5OCwiaWF0IjoxNjI2NzEyNzk4LCJuYmYiOjE2MjY3MTI3OTgsInByaXZhdGVDbGFpbXMiOnsiY29udGV4dCI6IkFBQUFBQUFBQUFDWFBEU1FPNldCNURRZG9RaCtXRHZjS2dFQUFBQUFBQUE2aVpRZUVXeHoyTG9zdVRVQktXTmIzSXVCUU51cEZnMzgzdzZRUnVTN1U1eU5qQUF3a2puZVk2Si9DWS85TTN1QWFEMVQrZS9ndktVNVFOaWxCT3RpdEV4d3ZYdXVEekZ1WDdhQ1hCc2xlVWdYenNSZW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8uOqScwa-kQF4ax-LzOWKaOE-ZrTW75UGhf6LxNorGxEDDhzNajObdQt9NBGIoM-E-LcLX1rjKvUarDgHvbQFLMt5HzjKNBSJjJ-ZyQodmI-7qDijf5vag3ea6ITEP1jciU5A0iMAtZNhKDNp0hgt7oyfYypRihWklSFrj21KXBjwo0nO0mJyA-Q81jAJU-wjxLDLXm6btsD4z4NWtHYMkjiEcjXfPhE6MyFNEH1_jPU6HbnOl1xRQJkEtTZeb6C44ZmzUkfrKRgWetWqfOr2GnF11vpKGk2_ueoNJZcBoJhzr57DiQ"
}
},
"request": {
"type": "SessionEndedRequest",
"requestId": "amzn1.echo-api.request.bf2b3b37-7260-4813-a43c-b94ae49b45bf",
"timestamp": "2021-07-19T16:40:08Z",
"locale": "en-US",
"reason": "ERROR",
"error": {
"type": "INVALID_RESPONSE",
"message": "An exception occurred while dispatching the request to the skill."
}
}
}

If you are hosting skill in lambda, there may be a chance for timeout. Database operations may take time, meanwhile lambda closed the session.
I think following log line suggests the same.
**2021-07-19T16:40:08.023Z 6a416b77-5d2c-4ebe-8ac4-dec09f67e9b9 Task timed out after 8.01 seconds**
Also, we have to consider maximum time allowed for Alexa to receive the response from end point. It is good to cap the response by 8 secs. For more information : DeferredResponse

Related

Possible Notion API bug - Can't create Database Page with URL data

I have a Notion database that I'm trying to write to via the API.
I can write to text fields, but when I try to write to a URL field, I receive the following error:
{
"object": "error",
"status": 400,
"code": "validation_error",
"message": "body failed validation. Fix one:\nbody.properties.O?HT.id should be defined, instead was `undefined`.\nbody.properties.O?HT.name should be defined, instead was `undefined`.\nbody.properties.O?HT.start should be defined, instead was `undefined`."
}
This is the API description of that field:
"LinkedIn": {
"id": "O%3FHT",
"name": "LinkedIn",
"type": "url",
"url": {}
},
This is the body of the API POST request that's failing:
{
"parent": {
"database_id": "f016c02beeff4a34bf298ceb8a8a079f"
},
"properties": {
"title": [
{
"text": {
"content": "Mark Zuckerberg"
}
}
],
"%3DCzE": [
{
"text": {
"content": "CEO"
}
}
],
"HihI": [
{
"text": {
"content": "Facebook"
}
}
],
"JC%3BS": [
{
"text": {
"content": "Menlo Park, CA"
}
}
],
"O%3FHT": {
"url": "https://www.linkedin.com/in/mark-zuckerberg/"
},
"wS%7BN": {
"url": "https://www.linkedin.com/company/facebook/mycompany/verification/"
}
}
}
I'm basing the body contents on the Postman docs provided by Notion: https://www.postman.com/notionhq/workspace/notion-s-api-workspace/documentation/15568543-d990f9b7-98d3-47d3-9131-4866ab9c6df2

Alexa Presentation Language Document rendering while speaking

I am trying to render an Alexa Presentation Language document while Alexa is speaking her speech. I tried with a pager with several pages and the AutoPager command. The problem I am trying to solve is that the document is rendered when Alexa starts speaking but the command is started when the speech is finished, and I would like to see the three pages moving while speaking.
I am using the RenderDocumet and the executeCommand and the speak directives of responseBuilder.
The Document Template:
PagerDoc —>
{
"type": "APL",
"version": "1.0",
"theme": "dark",
"import": [],
"resources": [],
"styles": {},
"layouts": {},
"mainTemplate": {
"parameters": [
"datasource"
],
"item": [{
"type": "Container",
"items": [
{
"type": "Sequence",
"id": "pagerComponentId",
"scrollDirection": "vertical",
"numbered": true,
"width": "100vw",
"height": "100vh",
"alignItems": "center",
"justifyContent": "center",
"direction": "column",
"items": [
{
"type": "Image",
"source": "${datasource.app.properties.images.robot1}",
"position": "relative",
"width": "100vw",
"height": "100vh"
},
{
"type": "Image",
"source": "${datasource.app.properties.images.robot2}",
"position": "relative",
"width": "100vw",
"height": "100vh"
}
]
}
]
}
]
}
}
And the Directives:
var response = handlerInput.responseBuilder;
return response
.addDirective({
type : 'Alexa.Presentation.APL.RenderDocument',
token: 'pagerToken',
document : pagerDoc,
datasources : {
"app": {
"properties": {
"images": {
"robot1": "https://xxx/robot1.png",
"robot2": "https://xxx/robot2.png"
}
}
}
}
})
.addDirective({
type: 'Alexa.Presentation.APL.ExecuteCommands',
token: 'pagerToken',
commands: [
{
"type": "Parallel",
"commands": [
{
"type": "Scroll",
"componentId": "pagerComponentId",
"distance": 1
}
]
})
.speak(speechOutput)
.reprompt(repromptOutput)
.getResponse();
Could somebody tell me what should I do? If this is possible with Alexa?
Thanks a lot in advance and best regards,
Fernando
It's not posible yet. If you wait until the release of APL 1.1 (coming soon)
APL 1.1 will add onMount to the APL document which should allow for the execution of commands as soon as a document is loaded (eg. before alexa speaks)

Dialogflow is not detecting the intent with context

I am connecting to Dialogflow REST API v2beta1 to the method: projects.agent.sessions.detectIntent. In the first request I send a text and the response is returning the expected result which contains outputContexts; when I made the 2nd request I send the context and it should find the intent which is linked to that context, but instead of that it is returning the Default Fallback Intent.
What may be the problem on the 2nd request?
Here are the URL and requests with their respective responses, and below I added the screenshots of the intents expected to match.
URL
https://dialogflow.googleapis.com/v2beta1/projects/project-name/agent/sessions/12343:detectIntent
1st request
{
"queryInput":{
"text":{
"text":"play a video about love",
"languageCode":"en"
}
}
}
1st response
{
"responseId": "15a3b767-52fe-4fc2-8ffd-9d7bb9c6961a",
"queryResult": {
"queryText": "play a video about love",
"action": "video.play",
"parameters": {
"organization": "",
"tag": "Love",
"item": ""
},
"allRequiredParamsPresent": true,
"fulfillmentText": "Here is a video about Love!",
"fulfillmentMessages": [
{
"platform": "ACTIONS_ON_GOOGLE",
"simpleResponses": {
"simpleResponses": [
{
"textToSpeech": "Here is a video about Love!"
}
]
}
},
{
"text": {
"text": [
"Here is a video about Love!"
]
}
}
],
"outputContexts": [
{
"name": "projects/project-name/agent/sessions/12343/contexts/play-video",
"lifespanCount": 5,
"parameters": {
"tag": "Love",
"organization": "",
"tag.original": "love",
"item": "",
"organization.original": "",
"item.original": ""
}
}
],
"intent": {
"name": "projects/project-name/agent/intents/9e5d2bbc-81f3-4700-8740-01504b05443f",
"displayName": "video-play"
},
"intentDetectionConfidence": 1,
"languageCode": "en"
}
}
2nd request (where the problem should be)
{
"queryParams":{
"contexts":[
{
"name":"projects/project-name/agent/sessions/12342/contexts/play-video"
}
]
},
"queryInput":{
"text":{
"text":"that video matters a lot for me",
"languageCode":"en"
}
}
}
2nd response
{
"responseId": "40d1f94f-4673-4644-aa53-99c854ff2596",
"queryResult": {
"queryText": "that video matters a lot for me",
"action": "input.unknown",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentText": "Can you say that again?",
"fulfillmentMessages": [
{
"text": {
"text": [
"Sorry, what was that?"
]
}
}
],
"intent": {
"name": "projects/project-name/agent/intents/10c88e8d-f16a-4905-b829-f596d3b3c588",
"displayName": "Default Fallback Intent",
"isFallback": true
},
"intentDetectionConfidence": 1,
"languageCode": "en"
}
}
Screenshots of the intents expected to match
1st intent
2nd intent
Useful documentation
Doc of the method: https://dialogflow.com/docs/reference/api-v2/rest/v2beta1/projects.agent.sessions/detectIntent
Doc of the Context object: https://dialogflow.com/docs/reference/api-v2/rest/Shared.Types/Context
Doc of the Params object to be sent: https://dialogflow.com/docs/reference/api-v2/rest/v2beta1/QueryParameters
It looks like your second request has an incomplete context. Although you're specifying the name, you're not including the lifespanCount parameter. Since you're not providing a parameter, it defaults to 0, which means that it has timed out.
You should send back exactly what you received from the outputContext attribute in the previous reply.
{
"queryParams":{
"contexts":[
{
"name": "projects/project-name/agent/sessions/12343/contexts/play-video",
"lifespanCount": 5,
"parameters": {
"tag": "Love",
"organization": "",
"tag.original": "love",
"item": "",
"organization.original": "",
"item.original": ""
}
}
]
},
"queryInput":{
"text":{
"text":"that video matters a lot for me",
"languageCode":"en"
}
}
}

How to set review for revision using Gerrit REST API

I'm trying to setup Teamcity building and verifying patchsets from Gerrit. The last step should set Verified to -1 if build failed. I'm playing around with Gerrit REST API and I think I found a proper command:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#set-review
The documentation says:
As response a ReviewInfo entity is returned that describes the applied
labels.
My request looks like this:
POST <gerrit-url>/a/changes/I696f00f4968fcb35fa614ce6325499aa15367150/revisions/current/review
{
"message": "Build failed",
"labels": {
"Verified": -1
}
}
As a response I get full revision info:
{
"id": "dev_test~master~<change-id>",
"project": "dev_test",
"branch": "master",
"hashtags": [],
"change_id": "<change-id>",
"subject": "a test",
"status": "NEW",
"created": "2017-04-03 07:53:19.000000000",
"updated": "2017-04-04 08:47:34.000000000",
"submit_type": "MERGE_IF_NECESSARY",
"mergeable": true,
"insertions": 133,
"deletions": 7,
"unresolved_comment_count": 0,
"_number": 381,
"owner": {
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>",
},
"labels": {
"Code-Review": {
"all": [
{
"value": 1,
"date": "2017-04-04 08:47:34.000000000",
"permitted_voting_range": {
"min": -2,
"max": 2
},
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
}
],
"values": {
"-2": "This shall not be merged",
"-1": "I would prefer this is not merged as is",
" 0": "No score",
"+1": "Looks good to me, but someone else must approve",
"+2": "Looks good to me, approved"
},
"default_value": 0
},
"Verified": {
"all": [
{
"value": 0,
"permitted_voting_range": {
"min": -1,
"max": 1
},
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
}
],
"values": {
"-1": "Fails",
" 0": "No score",
"+1": "Verified"
},
"default_value": 0
}
},
"permitted_labels": {},
"removable_reviewers": [],
"reviewers": {
"REVIEWER": [
{
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
}
]
},
"current_revision": "913330441711b067899a664a60c78be518e547b4",
"revisions": {
"913330441711b067899a664a60c78be518e547b4": {
"kind": "REWORK",
"_number": 6,
"created": "2017-04-03 14:08:14.000000000",
"uploader": {
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
},
"ref": "refs/changes/81/381/6",
"fetch": {
"ssh": {
"url": "ssh://<url>",
"ref": "refs/changes/81/381/6"
},
"http": {
"url": "http://<url>",
"ref": "refs/changes/81/381/6"
}
}
}
}
}
It's not affected by request. Same response is returned when I send request using GET method or using POST method with invalid JSON in body(!)
Gerrit version is: 2.13.6-3008-gcdc381e
Do I something wrong?
PS. Here is similar question, but it isn't helpful: Gerrit set-review api doesn't work
EDIT:
It seems that I getting response from GET request not POST
I figured it out. It's not gerrit problem. I used http request and our server redirected to https with 301 which the Postman fallowed and returned response for GET request.

HTTP requests are tampered by other HTTP requests, with golang and standard library

cat main.go:
```
package main
import (
"encoding/json"
"log"
"net"
"net/http"
"net/http/fcgi"
"os"
)
func main() {
//setup the config
configFile := "config.json"
fd, err := os.Open(configFile)
if err != nil {
log.Fatalf("Can't open config file: %v", configFile)
}
CFG := config{}
err = json.NewDecoder(fd).Decode(&CFG)
if err != nil {
log.Fatalf("parse config error: %v", err)
}
//init DB connection
db.InitConnectionInfo(CFG.Database.Host, CFG.Database.Port, CFG.Database.Database, CFG.Database.Username, CFG.Database.Password)
//register HTTP handler
sessionHandler := &handlers.SessionHandler{}
http.Handle("/sessions", sessionHandler)
http.Handle("/sessions/", sessionHandler)
userHandler := &handlers.UserHandler{
Facebook: &oa.OAuth{AppId: CFG.Facebook.Key, Secret: CFG.Facebook.Secret},
Sina: &oa.OAuth{AppId: CFG.Sina.Key, Secret: CFG.Sina.Secret},
Google: &oa.OAuth{AppId: CFG.Google.Key, Secret: CFG.Google.Secret},
Tencent: &oa.OAuth{AppId: CFG.Tencent.Key, Secret: CFG.Tencent.Secret},
Mixpanel: &hu.Share{Token: CFG.Mixpanel.Token},
FacebookShare: &hu.Share{Token: CFG.Facebook.Token},
SinaShare: &hu.Share{Token: CFG.Sina.Token},
GoogleShare: &hu.Share{Token: CFG.Google.Token},
TencentShare: &hu.Share{Token: CFG.Tencent.Token},
}
http.Handle("/users", userHandler)
http.Handle("/users/", userHandler)
//and so on ...
//run server
log.Println("start listen: ", CFG.FcgiAddr)
l, _ := net.Listen("tcp", CFG.FcgiAddr)
log.Fatalf("server error is %v", fcgi.Serve(l, nil))
//##select {}
log.Println("end listen")
}
```
build it and deploy behind nginx.
then client query /users/1234567/places, /users/1234567, and so on...
get the response is {blank data}, {normal user(1234567) data} or {normal user(1234567) data}, {normal user(1234567) data}.
same prefix of query, and same handler, looks like it is overload the response by subsequent HTTP request.
How can I do it?
May need me to give an example of a response:
correct response is :
{
"meta": {
"code": 200,
"text": "OK"
},
"data": {
"count": 21,
"place-tag-maps": [{
"id": "95842310160384",
"place-id": "95551731663150",
"tag-id": "95551579750669",
"ct": "2014-07-01T09:07:28Z"
}, {
"id": "95842310160385",
"place-id": "95551731663150",
"tag-id": "95551579750694",
"ct": "2015-01-15T17:41:23Z"
}, {
"id": "96262389694470",
"place-id": "95551731663150",
"tag-id": "95910120456455",
"ct": "2016-07-18T13:11:39Z"
}, ...],
"places": [{
"id": "95551731663150",
"name": "Kam Fung Restaurant",
"address": "G/F, 41 Spring Garden Ln",
"coordinate": {
"latitude": 22.275576,
"longitude": 114.172582
},
"telephone": "+852 2572 0526",
"city-id": "95530516807703",
"city": "Hong Kong",
"country": "Hong Kong",
"type": "4sq",
"ref-id": "4b1613f8f964a520cdb623e3",
"ct": "2016-02-23T07:42:43.565489Z",
"mt": "2017-02-22T09:35:48.302929Z",
"rating": 7.5,
"stats": {
"foursquare": {
"count": 111,
"value": 7.5
},
"spottly": {
"save-count": 12
}
},
"permanent-close": false,
"price": ""
}, ...],
"posts": [{
"collection-id": "95551746474003",
"coordinate": {
"latitude": 22.275576,
"longitude": 114.172582
},
"ct": "2017-02-22T09:35:47Z",
"facebook-tag-users": [],
"id": "97501586849795",
"medias": [],
"message": "",
"mt": "2017-02-22T09:35:47Z",
"owner-id": "96527264645120",
"place-id": "95551731663150",
"share-to": [],
"star": 5,
"status": "Done",
"tags": []
}, ...],
"users": [{
"id": "95551581323446",
"uid": "hk_epicurus",
"uid-ignore-case": "hk_epicurus",
"name": "Hk Epicurus",
"head": "https://d278wa0j9nq2mp.cloudfront.net/uploader/54aa335ddf4e63450002919a.jpeg",
"site": "www.hkepicurus.com",
"location": "Hong Kong",
"description": "Hong Kong Food \u0026 Travel Bear.\nGrew up in Aust, Malaysia, Tokyo \u0026 HK. \nInstagram: EpicurusHongKong\nFacebook, Spottly \u0026 Twitter: HK Epicurus \n微博: 香港美食-伊比\nFacebook Fans Page: http://on.fb.me/1qDyiIk",
"ct": "2013-10-13T19:12:41Z",
"mt": "2015-11-08T15:22:45Z"
}, ...]
}
}
and
{
"meta": {
"code": 200,
"text": "OK"
},
"data": {
"friends": [{
"id": "97331335725056",
"from-id": "97273770803200",
"to-id": "96527264645120",
"ct": "2017-01-23T07:58:41Z"
}],
"user": {
"ct": "2013-04-30T23:30:05Z",
"description": "Founder and Chief Everything Officer of Spottly. Loves to eat. Have a really bad memory. Wants to remember the best places and make travel research better",
"followers": {
"count": 41291
},
"followings": {
"count": 322
},
"head": "https://d278wa0j9nq2mp.cloudfront.net/uploader/525ffac8df4e6347870145ef.jpeg",
"id": "96527264645120",
"location": "Vancouver | Hong Kong | Beijing ",
"mt": "2015-10-27T09:47:12Z",
"name": "Edwyn Chan",
"site": "http://spottly.com/edwyn",
"uid": "edwyn",
"uid-ignore-case": "edwyn"
}
}
}
but mistake response is
{
"meta": {
"code": 200,
"text": "OK"
}
}
and
{
"meta": {
"code": 200,
"text": "OK"
},
"data": {
"friends": [{
"id": "97331335725056",
"from-id": "97273770803200",
"to-id": "96527264645120",
"ct": "2017-01-23T07:58:41Z"
}],
"user": {
"ct": "2013-04-30T23:30:05Z",
"description": "Founder and Chief Everything Officer of Spottly. Loves to eat. Have a really bad memory. Wants to remember the best places and make travel research better",
"followers": {
"count": 41291
},
"followings": {
"count": 322
},
"head": "https://d278wa0j9nq2mp.cloudfront.net/uploader/525ffac8df4e6347870145ef.jpeg",
"id": "96527264645120",
"location": "Vancouver | Hong Kong | Beijing ",
"mt": "2015-10-27T09:47:12Z",
"name": "Edwyn Chan",
"site": "http://spottly.com/edwyn",
"uid": "edwyn",
"uid-ignore-case": "edwyn"
}
}
}
the first response is error. or it's same as the second response.
sequence request is correct response, parallel request is incorrect response.
problem resolved。
the basic reason is this case:
var x = &{...} //init value
fillX(..., x) //fill the fields of x pointer
//here the fields of x pointer is not same to inner of fillX func
so, change to
var x = &{...}
x = fullX(..., x)
the problem resolved.
but why go pointer is the behavior?
Finally, this problem resolved.
Because the http.Handle register path-pattern and handler pair, the handler is construct by register time only-once, not for any request of path-pattern.
if record info within handler, It will been change by after request.