-
Couldn't load subscription status.
- Fork 44
Description
Hi All,
After some investigation I'm having trouble with Azure functions.
This is a simple Azure function which receives a HTTP Trigger call with an application/json Content-Type.
The function works perfectly fine for all invocation as always.
However, we have added an additional field to our JSON payload which is "bytes": 1253.
To give some small context, the bytes field is just the length of a file we have passed to another system. So everything in this event is text or integer. When passing this to the function
When the addition "bytes" field is added to the payload, the function invocation/function app crashes and throws the following error.
System.Private.CoreLib: Exception while executing function: Functions.function_sanitization_updated. System.Private.CoreLib: node exited with code 1 (0x1). LanguageWorkerConsoleLog[error] Worker fe1bae70-3626-4feb-ade8-f446f7a943e1 uncaught exception (learn more: https://go.microsoft.com/fwlink/?linkid=2097909 ): TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received type number (2) at new NodeError (node:internal/errors:371:5) at Function.from (node:buffer:323:9) at t.fromTypedData (C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:18531) at o (C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:17646) at o (C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:17778) at t.getNormalizedBindingData (C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:18069) at new d (C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:11664) at t.CreateContextAndInputs (C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:10563) at C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:26140 at Generator.next (<anonymous>) at C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:25022 at new Promise (<anonymous>) at r (C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:24767) at t.invocationRequest (C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:25336) at l.<anonymous> (C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:39292) at l.emit (node:events:526:28) at addChunk (node:internal/streams/readable:315:12) at readableAddChunk (node:internal/streams/readable:289:9) at l.Readable.push (node:internal/streams/readable:228:10) at Object.onReceiveMessage (C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:82321) at Object.onReceiveMessage (C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:74609) at C:\Users\Work\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\node\dist\src\worker-bundle.js:2:48750 at processTicksAndRejections (node:internal/process/task_queues:78:11)Do mind the Received type number (2). Referring to the bytes field (also number 2) in the example below.
If we change the value of the bytes field to a string like so "bytes": "test" then the invocation does not crash and doesn't throw an error.
{
"event_id": "04966b69-569b-4345-9d52-608e9fe82ccb",
"event_type": "TEST",
"event_creator": "TEST",
"timestamp": "2022-07-04T17:13:25.211Z",
"payload": {
"dossier_id": "TEST_DOS",
"test": {
"bytes": 2
}
}
}
I believe that something in the function source code checks for a "bytes" text and tries to parse it ?
The issue only occurs when the "bytes" field is at least 3 levels deep into the JSON object.
It's unbelievable and frustrating to have to be looking for this bug 🗡️ .
Hope someone can investigate and possibly resolve it.
PS: We're using typescript and it is being decompiled into JavaScript.
The function packages i've been using to test this replication are
azure-functions-core-tools@4.0.4590
@azure/functions": "^1.2.3
@azure/functions": "^3.2.0
- npm i
- tsc
- func start ...
{
"statusCode": 500,
"headers": {
"Request-Context": "appId=cid-v1:54e7f4c3-3fb0-4c1e-951d-da13708c851c",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"Date": "Wed, 06 Jul 2022 09:24:12 GMT",
"Content-Length": "0"
}
}Above is the response from the function that I've found somewhere on Azure so unsure if it's the correct request-context id for someone to take a look.