Azure / Azure/azure-functions-host
Payload of content-type application/x-protobuf is converted to UTF8 string
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
Function app version: 2.0
Timestamp: now
**Setup**
The task of my azure function, implemented in Javascript/node, is to decode a serialized protobuf message. In the node function body, the protobuf node library 'google-proto-files' is used.
Therefore, an invoking caller sends an HTTP POST request to my azure function endpoint, containing:
- http method: POST
- header Content-Type: *application/x-protobuf*
- binary payload, (i.e. a serialized byte[] buffer), which represents a serialized protobuf message.
**Expected result**
- The binary protobuf message payload arrives to the azure function body identically as it was sent away from the invoking caller.
- my azure function is able to decode my protobuf message successfully.
**Actual result**
- the binary protobuf message payload obtained in my azure function implementation differs in certain values:
- example: a byte value of 163 gets converted to 253
- my azure function is *not* able to decode the protobuf message.
**Observations**
- When changing the content-type header to *application/octet-stream* in the HTTP request, the payload seems *not* to be modified and decoding the received binary protobuf message works.
- The parameter "dataType: binary" in the HTTP function binding for the in direction does not have any effect.
- It seems that the payload of any content-type, except application/json and application/octet-stream, is converted to a utf8 string here:
- https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script/Rpc/MessageExtensions/RpcMessageConversionExtensions.cs#L104
Contributor guide
Research direction
Start in src/WebJobs.Script/Rpc/MessageExtensions/RpcMessageConversionExtensions.cs at the referenced line and trace how application/x-protobuf payloads are converted. Compare that path with application/octet-stream, then verify that protobuf bytes remain unchanged and that the existing HTTP function binding behavior still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, javascript
- Domain
- api, backend, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100