microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
732 stars 243 forks source link

"NavHttpContent variable not initialized" thrown in newest Business Central release #7574

Closed HrolfurHj closed 10 months ago

HrolfurHj commented 10 months ago

1. Describe the bug The error message: Microsoft.Dynamics.Nav.Runtime.NavHttpContent variable not initialized. is thrown when calling HttpContent.GetHeaders(HttpHeaders) after HttpContent.Clear() and before HttpContent.WriteFrom(Text). This only happens in the newest release of Business Central and caused runtime errors with our customers because our tests did not cover the code calling a web service.

Seems the main issue is the HttpContent.Clear() procedure working differently than before and somehow "un-initializing" the variable.

2. To Reproduce Simply call HttpContent.GetHeaders(HttpHeaders) after HttpContent.Clear() and before HttpContent.WriteFrom(Text)

procedure ContentErrorSample()
var
        content: HttpContent;
        headers: HttpHeaders;
begin
        content.Clear();
        content.GetHeaders(headers);
end;

3. Expected behavior I expect no error to show up and the Content variable to be actually initialized. This worked before actually and you could set some headers before writing the content, though Content-Type and other headers got overwritten.

4. Actual behavior "Microsoft.Dynamics.Nav.Runtime.NavHttpContent variable not initialized." is thrown when calling HttpContent.GetHeaders(HttpHeaders) after HttpContent.Clear()

5. Versions:

BazookaMusic commented 10 months ago

Although this issue is out of scope for this repository because this is a runtime issue, the relevant team has already released a fix for this issue for the runtime.

It will arrive on all environments around the world within the next week.

The issue was a regression introduced to how the http content is cleared in the last release.

Thus, I will close this issue