While migrating panva / node-oidc-provider package in nestjs from version 6 to 7.11 getting error 'interaction session not found' - node-oidc-provider

hi i am getting interactions and sessions created in mongo collection. however i am getting below error.
at resumeAction (/app/iam-authorization-server-microservice/node_modules/oidc-provider/lib/actions/authorization/resume.js:28:11)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async sessionHandler (/app/iam-authorization-server-microservice/node_modules/oidc-provider/lib/shared/session.js:29:5)
at async noCache (/app/iam-authorization-server-microservice/node_modules/oidc-provider/lib/shared/no_cache.js:3:3)
at async authorizationErrorHandler (/app/iam-authorization-server-microservice/node_modules/oidc-provider/lib/shared/authorization_error_handler.js:53:7)
at async ensureSessionSave (/app/iam-authorization-server-microservice/node_modules/oidc-provider/lib/helpers/initialize_app.js:50:7)
at async contextEnsureOidc (/app/iam-authorization-server-microservice/node_modules/oidc-provider/lib/shared/context_ensure_oidc.js:4:5)
at async /app/iam-authorization-server-microservice/node_modules/oidc-provider/lib/helpers/initialize_app.js:245:5
at async errorHandler (/app/iam-authorization-server-microservice/node_modules/oidc-provider/lib/shared/error_handler.js:26:7) {
allow_redirect: true,
error: 'invalid_request',
status: 400,
statusCode: 400,
expose: true,
error_description: 'interaction session not found',
error_detail: undefined
}```

Related

SendTransactionError: failed to send transaction: Node is unhealthy

I'm trying to send a transaction with a memo program inside it.
The problem appears on solana cli and web3 too.
This is the command:
solana transfer --from ./.cache/solana.json RECIVER_PUBLIC_KEY 0.00001 --allow-unfunded-recipient --url https://api.testnet.solana.com --fee-payer ./.cache/solana.json --with-memo hello
and this the response:
Error: RPC response error -32005: Node is unhealthy
The same with typescript/js snippet:
async function sendRawTransaction(message:string):Promise<string>{
const connection = await new Connection(CONNECTION_STRING);
let tx = new Transaction().add(
SystemProgram.transfer({
fromPubkey: WALLET.publicKey,
toPubkey: RECIVER_ADDRESS,
lamports: 0,
}),
);
await tx.add(
new TransactionInstruction({
keys: [{ pubkey: WALLET.publicKey, isSigner: true, isWritable: true }],
data: Buffer.from(message, "utf-8"),
programId: MEMO_PROGRAM,
})
);
return new Promise((res, rej)=>{
sendAndConfirmTransaction(connection, tx, [WALLET]).then(s=>{
console.log(s)
res(s)
}).catch(e=>{
console.log(e)
rej(e)
})
})
}
and the response is:
SendTransactionError: failed to send transaction: Node is unhealthy
at Connection.sendEncodedTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/#solana/web3.js/lib/index.cjs.js:6812:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Connection.sendRawTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/#solana/web3.js/lib/index.cjs.js:6769:20)
at async Connection.sendTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/#solana/web3.js/lib/index.cjs.js:6759:12)
at async sendAndConfirmTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/#solana/web3.js/lib/index.cjs.js:2219:21) {
logs: undefined
}
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
SendTransactionError: failed to send transaction: Node is unhealthy
at Connection.sendEncodedTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/#solana/web3.js/lib/index.cjs.js:6812:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Connection.sendRawTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/#solana/web3.js/lib/index.cjs.js:6769:20)
at async Connection.sendTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/#solana/web3.js/lib/index.cjs.js:6759:12)
at async sendAndConfirmTransaction (/Users/manueltardivo/Sviluppo/Notarify/Refactor/ntf-blackbox/node_modules/#solana/web3.js/lib/index.cjs.js:2219:21) {
logs: undefined
}
Node.js v18.4.0
[nodemon] app crashed - waiting for file changes before starting...
I've already tried to delete node_modules and re install them.
Could be a problem with the RPC provider?
Copying my answer from https://solana.stackexchange.com/questions/4303/solana-error-creating-memo-program-node-is-unhealthy-solana-web3/
Under normal circumstances, "node is unhealthy" often means that the node has fallen behind from the rest of the network, so you either need to wait for it to catch up, or you need to use another RPC node.
However, I can tell you that testnet is currently down, so you'll need to use another network until it's back up, either devnet or a local solana-test-validator.

Unfurl link outside bot conversation

When i post a link outside the bot conversation, like in a conversation with a coworker, i've an error saying "The bot is not part of a conversation roster"
It's working inside the bot conversation !
I've following this step-by-step guide, except the step "Update the Azure AD app registration"! My problem can't be related to this?
Bot builder JS version is "4.15.0"
The full stack trace
Trace: RestError: The bot is not part of the conversation roster.
at new RestError (/node_modules/#azure/ms-rest-js/dist/msRest.node.js:1403:28)
at /node_modules/#azure/ms-rest-js/dist/msRest.node.js:2528:37
at processTicksAndRejections (internal/process/task_queues.js:95:5) {
code: 'BotNotInConversationRoster',
statusCode: 403,
request: WebResource {
streamResponseBody: false,
url: 'https://smba.trafficmanager.net/fr/v3/conversations/19%3A6d034d50-90a1-4551-8029-23d63f85c195_ebe09ddb-51a0-4d40-9e7e-5839782cd8c9%40unq.gbl.spaces/members',
method: 'GET',
headers: HttpHeaders { _headersMap: [Object] },
body: undefined,
query: undefined,
formData: undefined,
withCredentials: false,
abortSignal: undefined,
timeout: 0,
onUploadProgress: undefined,
onDownloadProgress: undefined,
proxySettings: undefined,
keepAlive: undefined,
agentSettings: undefined,
operationSpec: {
httpMethod: 'GET',
path: 'v3/conversations/{conversationId}/members',
urlParameters: [Array],
responses: [Object],
serializer: [Serializer]
}
},
response: {
body: '{"error":{"code":"BotNotInConversationRoster","message":"The bot is not part of the conversation roster."}}',
headers: HttpHeaders { _headersMap: [Object] },
status: 403
},
body: {
error: {
code: 'BotNotInConversationRoster',
message: 'The bot is not part of the conversation roster.'
}
}
}
at BotFrameworkAdapter.onTurnErrorHandler [as turnError] (/lib/index.js:58:13)
at BotFrameworkAdapter.<anonymous> (/node_modules/botbuilder-core/lib/botAdapter.js:150:32)
at Generator.throw (<anonymous>)
at rejected (/node_modules/botbuilder-core/lib/botAdapter.js:6:65)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
I'm stuck with it, because I don't known if the unfurl link are expected to work outside conversation with the bot.
-- Edit --
This error was not related to the unfurl link, i was retrieving some information in the context only available during a conversation roaster.

Fix RestError Bot Framework

How do I fix this problem. Been lately receiving this causing my bot to be unresponsive.
I use node v8.11.2 and bot framework sdk v4 botbuilder version 4.8.0.
Thank you!
UPDATE:
when I add console.error(error) this shows up:
code: undefined,statusCode: 401,request:WebResource {streamResponseBody: false,url:'https://facebook.botframework.com/v3/conversations/2073757266064270-1820074761374022/activities/IaVk3v72Rl1',method: 'POST',headers: HttpHeaders { _headersMap: [Object] },body:'{"type":"typing","serviceUrl":"https://facebook.botframework.com/","channelId":"facebook","from":{"id":"1820074761374022"},"conversation":{"id":"2073757266064270-1820074761374022"},"recipient":{"id":"2073757266064270"},"replyToId":"IaVk3v72Rl1"}',query: undefined,formData: undefined,withCredentials: false,abortSignal: undefined,timeout: 0,onUploadProgress: undefined,onDownloadProgress: undefined,operationSpec:{ httpMethod: 'POST',path: 'v3/conversations/{conversationId}/activities/{activityId}',urlParameters: [Array],requestBody: [Object],responses: [Object],serializer: [Serializer] } },response:{ body: '',headers: HttpHeaders { _headersMap: [Object] },status: 401 },body: undefined }
ERROR in my other bot:
[onTurnError] unhandled error: Error
(node:11104) UnhandledPromiseRejectionWarning: Error: BotFrameworkAdapter.processActivity(): 500 ERRORErrorat new RestError (D:\home\site\wwwroot\node_modules#azure\ms-rest-js\dist\msRest.node.js:1397:28)at D:\home\site\wwwroot\node_modules#azure\ms-rest-js\dist\msRest.node.js:1849:37at process._tickCallback (internal/process/next_tick.js:68:7)at BotFrameworkAdapter. (D:\home\site\wwwroot\node_modules\botbuilder\lib\botFrameworkAdapter.js:638:27)
at Generator.throw ()at rejected (D:\home\site\wwwroot\node_modules\botbuilder\lib\botFrameworkAdapter.js:13:65)at process._tickCallback (internal/process/next_tick.js:68:7)(node:11104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 15)
This can happen if your Facebook token expires. Unfortunately, we don't have a way to refresh it, ourselves. To fix it, delete the Facebook channel, then re-add it following these instructions.

Where do I handle feathersjs/socketio-client connection error

I'm using feathers with socketio in backend. The client is listening and everything works well.
I want to handle the 'server not responding' error and I don't find where can I do that?
The error thrown by the server:
"Unhandled promise rejection
Object { type: "FeathersError", name: "Timeout", message: "Timeout of 5000ms exceeded calling find on newsfeed", code: 408, className: "timeout", data: {…}, errors: {}, stack: "FeathersError#webpack-internal:///./node_modules/#feathersjs/errors/lib/index.js:58:19\nTimeout#webpack-internal:///./node_modules/#feathersjs/errors/lib/index.js:135:3\nsend/</timeoutId<#webpack-internal:///./node_modules/#feathersjs/transport-commons/lib/client.js:66:9\n" }"
It is correct, the 'promise' is not handled! Where do I handle?
I tried adding catch on each line just to see what works but without success:
import feathers from '#feathersjs/feathers'
import socketio from '#feathersjs/socketio-client'
import io from 'socket.io-client'
const socket = io('http://localhost:3030/', {transports: ['websocket']});
socket.on("connect_failed", er=>console.error('Error connecting to server: ', er));
const restApi = feathers()
.configure(socketio(socket));
try {
restApi.service('/newsfeed');
restApi.on("connect_failed", er=>console.error('Error connecting to server: ', er));
}
catch (er) {
console.error('Error connecting to server: ', er)
}
export default restApi
The timeout error is coming from a particular request so you have to handle it wherever you are making the request.
restApi.service('/newsfeed').find()
If you're using async/await, you can wrap your service call in a try/catch or my personal favorite is just putting a catch on the call;
// try/catch
try {
const response= await restApi.service('/newsfeed').find();
catch(e) {
// handle e
}
//just use catch
const response= await restApi.service('/newsfeed').find().catch(e => {
// handle e
});
If you're using promises, just use a catch:
restApi.service('/newsfeed').find().then(response => {
// handle response
}).catch(e => {
// handle e
});

Dialogflow v2 client library not working | Error: Could not load the default credentials

here is their sample code:
const dialogflow = require('dialogflow');
const uuid = require('uuid');
/**
* Send a query to the dialogflow agent, and return the query result.
* #param {string} projectId The project to be used
*/
async function runSample(projectId = 'your-project-id') {
// A unique identifier for the given session
const sessionId = uuid.v4();
// Create a new session
const sessionClient = new dialogflow.SessionsClient();
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
// The text query request.
const request = {
session: sessionPath,
queryInput: {
text: {
// The query to send to the dialogflow agent
text: 'hello',
// The language used by the client (en-US)
languageCode: 'en-US',
},
},
};
// Send request and log result
const responses = await sessionClient.detectIntent(request);
console.log('Detected intent');
const result = responses[0].queryResult;
console.log(` Query: ${result.queryText}`);
console.log(` Response: ${result.fulfillmentText}`);
if (result.intent) {
console.log(` Intent: ${result.intent.displayName}`);
} else {
console.log(` No intent matched.`);
}
}
and this code is not working at all, giving Error: Could not load the default credentials :
2019-03-21T16:59:40.099101+00:00 app[web.1]: Message: hi Bilal
2019-03-21T16:59:40.102561+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
2019-03-21T16:59:40.102565+00:00 app[web.1]: at GoogleAuth.<anonymous> (/app/web/node_modules/google-auth-library/build/src/auth/googleauth.js:168:23)
2019-03-21T16:59:40.102568+00:00 app[web.1]: at Generator.next (<anonymous>)
2019-03-21T16:59:40.102570+00:00 app[web.1]: at fulfilled (/app/web/node_modules/google-auth-library/build/src/auth/googleauth.js:19:58)
2019-03-21T16:59:40.102572+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:68:7)
2019-03-21T16:59:40.102691+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2019-03-21T16:59:40.102784+00:00 app[web.1]: (node:23) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2019-03-21T16:59:55.986568+00:00 app[web.1]: Message: hi Bilal
2019-03-21T16:59:55.986595+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
2019-03-21T16:59:55.986598+00:00 app[web.1]: at GoogleAuth.<anonymous> (/app/web/node_modules/google-auth-library/build/src/auth/googleauth.js:168:23)
2019-03-21T16:59:55.986600+00:00 app[web.1]: at Generator.next (<anonymous>)
2019-03-21T16:59:55.986602+00:00 app[web.1]: at fulfilled (/app/web/node_modules/google-auth-library/build/src/auth/googleauth.js:19:58)
2019-03-21T16:59:55.986605+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:68:7)
2019-03-21T16:59:55.986647+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
they have instructions how to use this library in the repo but it doesnt makes sense https://github.com/googleapis/nodejs-dialogflow
they have not described anywhere how to put credentials while calling detect intent, not eve in the example code here: https://github.com/googleapis/nodejs-dialogflow/blob/master/samples/detect.js
I have never seen such irresponsible team like dialogflow team in my life
Update:
exporting env variable solved my problem and now I am getting something back from dialogflow but not as expected, may be they have incorrect code in their repository sample code
this is the code they do have as try an example:
...
// Send request and log result
const responses = await sessionClient.detectIntent(request);
console.log('Detected intent');
const result = responses[0].queryResult;
console.log(` Query: ${result.queryText}`);
console.log(` Response: ${result.fulfillmentText}`);
if (result.intent) {
console.log(` Intent: ${result.intent.displayName}`);
} else {
console.log(` No intent matched.`);
}
...
and in fact result.fulfillmentText does not exist, it is giving me undefined
Update 2
that much effort I have done(see console.logs below) just to understand that instead of responses[0].queryResult.fulfillmentText now they return responses[0].queryResult.fulfillmentMessages and it is not a text string but it is an object which have further values in it that you can see in console.logs below:
...
// Send request and log result
const responses = await sessionClient.detectIntent(request);
console.log('Detected intent');
console.log("responses: ", responses)
console.log("responses[0]: ", responses[0])
console.log("responses[0].queryResult: ", responses[0].queryResult)
console.log("responses[0].queryResult.fulfillmentMessages: ", responses[0].queryResult.fulfillmentMessages)
// console.log("responses[0].queryResult.fulfillmentMessages[1]: ", responses[0].queryResult.fulfillmentMessages[1])
console.log("responses[0].queryResult.fulfillmentMessages[0]: ", responses[0].queryResult.fulfillmentMessages[0])
console.log("responses[0].queryResult.fulfillmentMessages[0].text: ", responses[0].queryResult.fulfillmentMessages[0].text)
console.log("responses[0].queryResult.fulfillmentMessages[0].text.text: ", responses[0].queryResult.fulfillmentMessages[0].text.text)
console.log("responses[0].queryResult.fulfillmentMessages[0].text.text[0]: ", responses[0].queryResult.fulfillmentMessages[0].text.text[0])
var fulfilmentText = responses[0].queryResult.fulfillmentMessages[0].text.text[0]
...
The google auth library is looking for an environment variable called
GOOGLE_APPLICATION_CREDENTIALS that points to a JSON credentials file.
You can download that file by following instructions as described in https://dialogflow.com/docs/reference/v2-auth-setup.
The link after the error message has examples of how to set that environment variable:
https://cloud.google.com/docs/authentication/getting-started
Have you tried taking a look at this? You'll need to set up authentication, create a service account key as a .json then have Google Cloud SDK handle it.
https://dialogflow.com/docs/reference/v2-auth-setup
You can also try passing in the service account like this
// Create a new session
const sessionClient = new dialogflow.SessionsClient({keyFilename: "./service_account.json"});

Resources