Difference in response header handling between v3 and v4 – undefined headers included in v4

Theja Aragonda 20 Reputation points
2026-02-07T13:02:30.58+00:00

While migrating from v3 to v4, we observed a change in response header behavior.

In v3, when a response header value was undefined, the corresponding header property was not included in the final response while subscribing via the UI.

In v4, the response object returns the header property with the string value 'undefined', instead of omitting the header.

This results in a behavioral difference between v3 and v4.

Example response headers sent from the API in v4:

{
  headers: {
  'page-token': undefined,
  'total-count': 0,
  'access-control-expose-headers': 'page-token, total-count',
  'Content-Security-Policy': "default-src 'none'; frame-ancestors 'none'",
  'Strict-Transport-Security': 'max-age=63072000',
  'X-Content-Type-Options': 'nosniff'
  }
}

Question:

Is this a known behavior change between v3 and v4? If so, is there any recommended approach in v4 to ensure headers with undefined values are omitted, similar to v3 behavior?

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

Answer accepted by question author
Praveen Kumar Gudipudi 2,295 Reputation points Microsoft External Staff Moderator
2026-02-09T09:04:53.69+00:00

Hello Theja Aragonda,

Yes — this is an expected behavioral difference between v3 and v4, and it stems from internal changes in how the response pipeline serializes headers rather than a functional regression.

Behavior difference between v3 and v4

v3 behavior:

Headers with value undefined were not serialized into the final HTTP response.

Result:

→ Missing/undefined headers were silently omitted.

v4 behavior:

The runtime now preserves header keys even when the value is undefined.

During serialization, undefined is converted into the string "undefined".

Result:

→ Header appears in the response instead of being omitted.

This change is caused by:

Updated HTTP response handling in the v4 runtime

Alignment with JavaScript object serialization semantics

More explicit header visibility for debugging/inspection

So yes — this is known and expected behavior, not a defect.

Recommended approach in v4

To restore v3-style omission behavior, headers must be filtered before sending the response.

Option 1 – Remove undefined headers explicitly:

const cleanedHeaders = Object.fromEntries(

Object.entries(headers).filter(([_, v]) => v !== undefined)

);

return {

status: 200,

headers: cleanedHeaders,

body: responseBody

};

Option 2 – Set null instead of undefined

'page-token': null

Please accept as answer and do a Thumbs-up to upvote this response if you are satisfied with the community help. Your upvote will be beneficial for the community users facing similar issues.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.