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

Handle undefined tags #40

Merged
merged 1 commit into from Jul 31, 2018
Merged

Handle undefined tags #40

merged 1 commit into from Jul 31, 2018

Conversation

@Shwetajain148
Copy link

@Shwetajain148 Shwetajain148 commented Jul 20, 2018

In this PR, I have handled the undefined tag issue loggly/winston-loggly-bulk#33 which crashes the whole app.

I've covered the below points in this bug fix-

(a) Calculate the tag length only when there is actually any tag defined. Ref- #233
(b) Set the X-LOGGLY-TAG property into the request header only when there is actually a tag length into the tag array. Ref- #180
(c) In Bulk mode, the X-LOGGLY-TAG property sets again to make the Loggly URL so modified the code to use this propertry only when the headers 'X-LOGGLY-TAG' contains some value. Ref - #150

I have tested it initially and found working now. But complete testing is still in-progress.

UPDATE: It has been tested successfully so it's ready to merge.

Thanks!

//
if (tags) {
if (tags && tags.length) {

This comment has been minimized.

@Shwetajain148

Shwetajain148 Jul 23, 2018
Author

Set the headers['X-LOGGLY-TAG'] property only when we have some actual tag defined into the tag array not undefined.

@@ -227,7 +230,7 @@ Loggly.prototype.tagFilter = function (tags) {
//
// Remark: length may need to use Buffer.byteLength?
//
return isSolid.test(tag) && tag.length <= 64;
return tag && isSolid.test(tag) && tag.length <= 64;

This comment has been minimized.

@Shwetajain148

Shwetajain148 Jul 23, 2018
Author

Calculate the tag's length only when tag actually has some value otherwise return.

@@ -147,7 +147,7 @@ common.loggly = function () {
}
}
var requestOptions = {
uri: isBulk ? uri + '/tag/' + headers['X-LOGGLY-TAG'] : uri,
uri: (isBulk && headers['X-LOGGLY-TAG']) ? uri + '/tag/' + headers['X-LOGGLY-TAG'] : uri,

This comment has been minimized.

@Shwetajain148

Shwetajain148 Jul 23, 2018
Author

Add headers['X-LOGGLY-TAG'] property into the request header only when the logging mode is Bulk and headers['X-LOGGLY-TAG'] contains some value. This will prevent logs sending from the undefined tag name.

@kevinegami kevinegami merged commit cfd27fc into loggly:master Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.