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

core: http - Error when performing a request with loggingFlushDisabled set to true #856

Closed
erwan-carlig opened this issue Nov 14, 2018 · 3 comments · Fixed by #881
Closed

Comments

@erwan-carlig
Copy link

erwan-carlig commented Nov 14, 2018

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/NationalBankBelgium/stark/blob/master/CONTRIBUTING.md#got-a-question-or-problem

Current behavior

When deserializing the stark-app-config.json (app.module.ts:99), by default the "loggingCorrelationIdHttpHeaderName" property is either set to the content of stark-app-config.json or to "correlation-id" (it can never be undefined).

If logging is disabled (loggingFlushDisabled set to true), the StarkLoggingServiceImpl will not generate a correlationId (logging.service.ts:69).

When using the stark http service, it will try to add the correlation headers (http.service.ts:176) and set the correlation id header to the value of correlationId coming from the StarkLoggingService (which is undefined since it was not generated).

When trying to perform the request it will cause any of the following errors:

ERROR TypeError: Cannot read property 'keys' of undefined
    at StarkHttpServiceImpl.ac_main../node_modules/@nationalbankbelgium/stark-core/fesm5/stark-core.js.StarkHttpServiceImpl.getResponseHeaders 
"Cannot read property 'length' of undefined" in file headers.ts:74 (@angular/common/http/src/headers.ts)

Expected behavior

No correlation header should be added if logging is disabled.

Others:

Not a pressing issue, I can work around it.

Environment


Angular version: 6.1.10
Stark version: 10.0.0-beta.1

@christophercr christophercr added this to the 10.0.0-beta.2 milestone Nov 14, 2018
@christophercr christophercr added the comp: stark-core Stark Core label Nov 14, 2018
@christophercr christophercr changed the title Error when performing a request with loggingFlushDisabled set to true core: http - Error when performing a request with loggingFlushDisabled set to true Nov 14, 2018
@christophercr
Copy link
Collaborator

Thanks for the report! We'll fix it in the next release ;)

@christophercr
Copy link
Collaborator

The issue boils down to the fact that Angular throws in case a header value is null or undefined. See angular/angular#18743

christophercr referenced this issue in christophercr/stark Nov 23, 2018
…ion service to prevent undefined and null header values to be added to Angular Http headers.

ISSUES CLOSED: #856
christophercr referenced this issue in christophercr/stark Nov 23, 2018
…ion service to prevent undefined and null header values to be added to Angular Http headers.

ISSUES CLOSED: #856
@erwan-carlig
Copy link
Author

erwan-carlig commented Dec 14, 2018

Hello,

Unfortunately the "loggingCorrelationIdHttpHeaderName" is added by the StarkHttpService's method "addCorrelationIdentifierHeader", which directly access the headers map and add the undefined header.
This bypass the StarkAbstractHttpBaseRequestBuilder method "setHeader" where you added an undefined check, hence the bug still occurs.

Thanks for the help :)

Edit: I worked around it by setting "loggingCorrelationIdHttpHeaderName" to an empty string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants