Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: HttpContent.SetHeader failing when secret header already exists #1479

Open
1 task done
vody opened this issue Jul 3, 2024 · 8 comments · May be fixed by #2474
Open
1 task done

[Bug]: HttpContent.SetHeader failing when secret header already exists #1479

vody opened this issue Jul 3, 2024 · 8 comments · May be fixed by #2474
Assignees
Labels
Approved The issue is approved Integration GitHub request for Integration area

Comments

@vody
Copy link

vody commented Jul 3, 2024

Describe the issue

The "Http Content" codeunit throws an error message when content is defined from SecretText.

Error message: 
Cannot add value because the header 'Content-Type' does not support multiple values.

AL call stack: 
"Http Content Impl."(CodeUnit 2355).SetHeader line 12 - System Application by Microsoft
"Http Content Impl."(CodeUnit 2355).SetContentTypeHeader line 4 - System Application by Microsoft
"Http Content Impl."(CodeUnit 2355).SetContent line 6 - System Application by Microsoft
"Http Content"(CodeUnit 2354).SetContent line 2 - System Application by Microsoft
"Http Content"(CodeUnit 2354).Create line 2 - System Application by Microsoft\"Http Content"(CodeUnit 2354).Create line 2 - System Application by Microsoft

This happens because inside "Http Content Impl.".SetHeader procedure Headers.Contains(Name) condition will return false for a secret header, which will be automatically created when we set a content from the SecretText value.

Expected behavior

Content will be defined with a new header without error.

Steps to reproduce

codeunit 50000 SetHeader
{
    trigger OnRun()
    var
        HttpContent: Codeunit "Http Content";
    begin
        HttpContent.Create(SecretStrSubstNo('anything'));
    end;
}

Additional context

No response

I will provide a fix for a bug

  • I will provide a fix for a bug
@vody vody added the Bug Something isn't working label Jul 3, 2024
@JesperSchulz JesperSchulz added the Approved The issue is approved label Jul 8, 2024
@JesperSchulz
Copy link
Contributor

@ajkauffmann has agreed to include this in a pull request he is working on anyway 🥳
I cannot assign it to him (seems I can only assign to people who have been active on the issue), but consider it assigned 😉

@ajkauffmann
Copy link
Contributor

I'm active now. 😊
Yes, happy to take this one!

@JesperSchulz
Copy link
Contributor

And now I could assign you 🥳

@vody
Copy link
Author

vody commented Sep 15, 2024

@ajkauffmann thank you for picking this one. We tried to use it internally to promote open-source contribution within an organization but it was pushed down in priority.

@JesperSchulz JesperSchulz added the Integration GitHub request for Integration area label Sep 16, 2024
@tuschacht
Copy link

tuschacht commented Oct 25, 2024

Is this issue fixed, because i have the same issue when i try to use a secretbody with Application/JSON as content-type.

If requesting support, please provide the following details to help troubleshooting:

Error message:
Cannot add value because header 'Content-Type' does not support multiple values.

Internal session ID:
501f404a-de0f-4dcf-aba3-6e58cd54fd3b

Application Insights session ID:
04d49ecd-dce5-4254-8280-4c7cfb6f8f21

Client activity id:
dcade827-4d0e-4725-8da6-d7b7f983ade0

Time stamp on error:
2024-10-25T08:02:59.2329934Z

User telemetry id:
8359f88c-83b9-4270-bc5a-b420f5a31509

AL call stack:
"Http Content Impl."(CodeUnit 2355).SetHeader line 12 - System Application by Microsoft
"Http Content Impl."(CodeUnit 2355).SetContentTypeHeader line 4 - System Application by Microsoft
"Http Content Impl."(CodeUnit 2355).SetContent line 6 - System Application by Microsoft
"Http Content"(CodeUnit 2354).SetContent line 2 - System Application by Microsoft
"Http Content"(CodeUnit 2354).Create line 2 - System Application by Microsoft

@ajkauffmann
Copy link
Contributor

Yes, a PR will be created next week!

@tuschacht
Copy link

Thank you for the Solution, this is just a major issue because i have a Customer who needs this solution ASAP and security is key.

@ajkauffmann
Copy link
Contributor

You can always use a workaround by creating a HttpContent object with the correct and use it with HttpContent.Create(HttpContent). Then you don't have to wait for the PR to be approved and backported to v25.

@aholstrup1 aholstrup1 removed the Bug Something isn't working label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved The issue is approved Integration GitHub request for Integration area
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants