Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Handle undefined tags #40
Merged
Conversation
| // | ||
| if (tags) { | ||
| if (tags && tags.length) { |
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.
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; | |||
Shwetajain148
Jul 23, 2018
Author
Calculate the tag's length only when tag actually has some value otherwise return.
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, | |||
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.
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
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!