When using a storage queue trigger with a JSON payload in the queue message properties from the deserialized payload are overwriting properties of InvocationContext.triggerMetadata.
The documentation defines the properties of triggerMetadata, but mentions nothing about the payload properties also being present so this appears to be undocumented behaviour.
More importantly it prevents accessing the metadata properties if there is a clash between the property names in the payload and metadata, and allows them to be overwritten with unexpected values.
Reproducing
@azure/functions version: 4.16.2
Function:
import { app } from '@azure/functions';
app.storageQueue('metadataOverwrite', {
queueName: 'some-queue-name',
connection: 'AzureWebJobsStorage',
handler: (payload, context) => {
context.log('payload id', (payload as any).id);
// should output message guid, but outputs payload id instead
context.log('queue message id', context.triggerMetadata?.id);
}
})
Queue message:
{
"id": "testing-id",
"propertyA": "abc"
}
Expected output:
payload id testing-id
queue message id [some guid]
Actual output:
payload id testing-id
queue message id testing-id
When using a storage queue trigger with a JSON payload in the queue message properties from the deserialized payload are overwriting properties of InvocationContext.triggerMetadata.
The documentation defines the properties of triggerMetadata, but mentions nothing about the payload properties also being present so this appears to be undocumented behaviour.
More importantly it prevents accessing the metadata properties if there is a clash between the property names in the payload and metadata, and allows them to be overwritten with unexpected values.
Reproducing
@azure/functions version: 4.16.2
Function:
Queue message:
{ "id": "testing-id", "propertyA": "abc" }Expected output:
Actual output: