I'm currently trying to deploy a Github bot to AWS Lambda. However, when testing the bot, there is a function in my code that causes an error.
The yamlFile() function gets the content of a file from a user's Github repo, and returns it. However, when tested, the function will get to the first trying to get yaml log, but never reach the second we got the yaml log.
There is also no error that is logged out as a result of the try/catch.
Since the AWS Lambda functions receives webhooks from AWS, this function is called multiple times (from multiple webhooks). This function runs correctly for the first call, but gives us the above issue on the second call.
Prior to deploying on AWS Lambda, this exact code was running on Heroku, and worked fine there, without any issue.
AWS Config settings:
30 sec timeout
2048mb memory
const yamlFile = async (context) => {
try {
console.log("trying to get yaml")
var yamlfile = await context.octokit.repos.getContent({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
path: ".bit/config.yml",
});
console.log("we got the yaml")
// console.log(yamlfile)
} catch (e) {
console.log("Error with getting content of yaml");
console.log(e)
return null
}
console.log("got yaml, but no content yet");
yamlfile = Buffer.from(yamlfile.data.content, 'base64').toString()
// console.log(yamlfile)
try {
let fileContents = yamlfile
configyml = yaml.load(fileContents);
} catch (e) {
const issueBody = context.issue({
title: "[ERROR] Please read",
body: `There was an issue parsing the config file of this course. Please contact your counselor and send them the below error.\n${e}`,
});
context.octokit.issues.create(issueBody)
console.log("ERROR: " + e);
return null
}
console.log("returining configyml")
return configyml;
}
That's a very specific question, better asked on Stackoverflow, which looks you already did. It looks most likely like an AWS Lambda issue, I cannot help with that, sorry
I'm currently trying to deploy a Github bot to AWS Lambda. However, when testing the bot, there is a function in my code that causes an error.
The
yamlFile()
function gets the content of a file from a user's Github repo, and returns it. However, when tested, the function will get to the firsttrying to get yaml
log, but never reach the secondwe got the yaml
log.There is also no error that is logged out as a result of the
try/catch
.Since the AWS Lambda functions receives webhooks from AWS, this function is called multiple times (from multiple webhooks). This function runs correctly for the first call, but gives us the above issue on the second call.
Prior to deploying on AWS Lambda, this exact code was running on Heroku, and worked fine there, without any issue.
AWS Config settings: