-
Notifications
You must be signed in to change notification settings - Fork 58
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
Sweep: Improve errors handling #169
Comments
🚀 Here's the PR! #170Search Results
ResponseI'll help implement the solution following the format guidelines. Let's break this down into multiple code changes:
|
Details
By the docs, the user needs to pass only
host
as anurl
option, so the exact URL is being built internally here:https://github.com/JaniAnttonen/winston-loki/blob/development/src/batcher.js#L42-L43
But if the user doesn't follow docs, or makes a typo, and passes not only a host but for example, a full URL, then internal implementation doesn't care about it and builds an invalid URL. Then, in the
req.post
, an invalid URL is being silently processed with no error, so in fact, no logs are being sent, and no error is being thrown. Here's the problem:https://github.com/JaniAnttonen/winston-loki/blob/development/src/batcher.js#L257-L272
Inside
then
, theresponse
argument should be handled, and if something bad happens, it should throw an error so thatcatch
can handle it correctly. For example, for an invalid URL theresponse
will have a text error saying404 URL not found
.Branch
No response
Improve Error Handling for Invalid URLs in Winston Loki Transport
Description:
Enhance error handling in the Batcher class to properly handle and report invalid URLs and HTTP response errors, particularly when users provide incorrect URL formats.
Tasks:
In
src/batcher.js
, update URL handling:host
parameter in constructorIn
src/batcher.js
, enhancesendBatchToLoki
method:Test:
In
test/batcher.json.test.js
, add tests:In
test/requests.test.js
, add tests:Additional Context:
The changes focus on the URL construction in the Batcher constructor and HTTP response handling in the
sendBatchToLoki
method to prevent silent failures when logs aren't being sent.The text was updated successfully, but these errors were encountered: