Skip to content

[Bug]: "Stor. Serv. Auth. Shared Key"(CodeUnit 9064).TryGetContentHeadersTryGetContentHeaders produces unnecessary error callstack #6647

@PaulFurlet

Description

@PaulFurlet

Describe the issue

I am using Azure Blob Storage module, and trying to catch potential connectivity errors in log.
So even despite successful run, there is always error in the callstack Microsoft.Dynamics.Nav.Runtime.NavHttpContent variable not initialized. generated by the TryGetContentHeaders procedure in codeunit 9064 "Stor. Serv. Auth. Shared Key"
This is behavior for any module using this method

Expected behavior

If execution of CreateSharedKeyStringToSign is successful, there must be no error callstack.

Steps to reproduce

    internal procedure BlobExists(ContainerName: Text; FileName: Text; SecretKey: SecretText; AccountName: Text) Result: Boolean
    var
        BlobClient: Codeunit "ABS Blob Client";
        StorageAuth: Codeunit "Storage Service Authorization";
        Auth: Interface "Storage Service Authorization";
    begin
        Auth := StorageAuth.CreateSharedKey(SecretKey);
        BlobClient.Initialize(AccountName, ContainerName, Auth);
        Result := BlobClient.BlobExists(FileName);
        if Result = true then
        if GetLastError() <> '' then
            Message('%1\%2', GetLastErrorText(), GetLastErrorCallStack())
    end;

assuming Azure Blob file exists and call is successful, I get error Microsoft.Dynamics.Nav.Runtime.NavHttpContent variable not initialized..
Callstack starts with "Stor. Serv. Auth. Shared Key"(CodeUnit 9064).TryGetContentHeaders

Additional context

the solution would be in changing the procedure from [TryFunction] to normal returning boolean:

    local procedure TryGetContentHeaders(var HttpRequestMessage: HttpRequestMessage; var RequestHttpHeaders: HttpHeaders) : Boolean
    begin
        exit(HttpRequestMessage.Content.GetHeaders(RequestHttpHeaders));
    end;

I will provide a fix for a bug

  • I will provide a fix for a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions