omnisnash / advent-of-code-leaderboard-microsoft-teams Goto Github PK
View Code? Open in Web Editor NEWAllow you to sent an Advent of Code (AoC) private leaderboard in a Microsoft Teams room via a Webhook connector.
License: MIT License
Allow you to sent an Advent of Code (AoC) private leaderboard in a Microsoft Teams room via a Webhook connector.
License: MIT License
My posts to Teams just stopped working yesterday after working perfectly the day before. GitHub actions were running and completing successfully, but nothing was showing up in Teams. It was like messages were being silently dropped.
When there is an issue sending the leaderboard message to the Teams webhook, this silently completes even if Teams is responding with an error.
So after a LOT of debugging, I discovered that Teams will return an error message in the response body if the submitted POST
has an issue. When the POST
is successful, the response body will be simply 1
with a 200 status code. But when the POST
fails, the response is still a 200 status code (why?!?!?) with an body message along the lines of:
Webhook message delivery failed with error: Microsoft Teams endpoint returned HTTP error 500 with ContextId tcid=0,server=msgapi-production-scus-azsc6-2-194,cv=ImZV3K0Hh0exYBE0orNutw.0,MS-CV=ImZV3K0Hh0exYBE0orNutw.0..
Why Teams wraps a 500 error with a 200 response is beyond me, but hey, at least there's something now to work from.
After a bunch more messing around, I figured out that the cause of the error was because the message was too large. It looks like about 16 users on a leaderboard is the maximum safe size of the message before Teams starts rejecting it. Any more rows and the message was too large. The hard limit is 28 KB
: https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook
I have a working solution and will open a PR shortly.
Hi there,
Having an issue converting the body of the response to JSON:
FetchError: invalid json response body at https://adventofcode.com/2020/leaderboard reason: Unexpected token < in JSON at position 0
at C:\Users\james\Documents\GitHub\advent-of-code-leaderboard-microsoft-teams\node_modules\node-fetch\lib\index.js:272:32
at processTicksAndRejections (node:internal/process/task_queues:93:5)
at async requestJsonLeaderboard (C:\Users\james\Documents\GitHub\advent-of-code-leaderboard-microsoft-teams\src\index.js:38:26)
at async C:\Users\james\Documents\GitHub\advent-of-code-leaderboard-microsoft-teams\src\index.js:53:29 {
type: 'invalid-json'
}
By no means a JS wizard, but would love to get this working for my team. Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.