lazywithclass/winston-cloudwatch

InvalidParameterException

Closed this issue · 6 comments

Sometimes this can occur InvalidParameterException: 1 validation error detected: Value '[]' at 'logEvents' failed to satisfy constraint: Member must have length greater than or equal to 1, I assume because the data being set is empty. It would be nice if this could be suppressed so you don't have to validate before logging somewhat arbitrary data, or if the data provided is empty, then this module could do the checks and format it so it would wouldn't error from aws sdk.

Hello, thanks for the report. Could you please show some code that reproduces the problem?
Either in the form of test, or small project, or just a file that uses the library.

This would help a lot in finding the issue.

Hello, I have the same problem as @btmdave.
I think this problem happens when the WinstonCloudWatch object is "waiting" for new logs.
If I understand well, WinstonCloudWatch will send an array of data to CloudWatch each 2 seconds (by default). However, if we don't have any data to send, WinstonCloudWatch will send an empty array to CloudWatch, in this case we get an error 400 by Amazon Cloud Watch.
Could it be possible to add in the library a condition to check if the array is empty or not? If this one is empty, don't send the data to CloudWatch.
I think this code could be in the prototype of CloudWatch object here : https://github.com/lazywithclass/winston-cloudwatch/blob/1b96debe3bfcbd9f44c0dd52fa0827135b8e1f66/index.js#L72
Thank you in advance for this improvement.
Best,

Aaah I get it!

Thank you so much for the explanation @FlorianBouron, I will have a look at this over the weekend.

Hi @lazywithclass , I made some improvement for my case of this error and about a "bug" I had in my Cloudwatch Log with "meta" data (point number 2).
I made a pull request.
Best,

Yes I had something similar going on in another branch, will check and let you know there.
Thanks for your help!

Closing here, continuing in the PR; @btmdave once the PR is merged please feel free to reopen here in case you still have the problem.