Skip to content

Commit e6f8545

Browse files
authored
Add retry for 0 StatusCode (#78)
* Add retry for 0 StatusCode Signed-off-by: Saswata Mukherjee <[email protected]> * Add changelog Signed-off-by: Saswata Mukherjee <[email protected]> * Add comment Signed-off-by: Saswata Mukherjee <[email protected]>
1 parent d68d51d commit e6f8545

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel
3030
* [#71](https://github.com/bwplotka/mdox/pull/71) Add `Origin.Path` to transform template
3131
* [#75](https://github.com/bwplotka/mdox/pull/75) Add `soft-wraps` flag to preserve soft line breaks
3232
* [#76](https://github.com/bwplotka/mdox/pull/76) Add `linkPrefixForNonMarkdownResources` to transform config
33+
* [#78](https://github.com/bwplotka/mdox/pull/78) Add retry for 0 StatusCode
3334

3435
### Fixed
3536

pkg/mdformatter/linktransformer/link.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ func NewValidator(ctx context.Context, logger log.Logger, linksValidateConfig []
284284
break
285285
}
286286
v.remoteLinks[response.Ctx.Get(originalURLKey)] = errors.Wrapf(err, "%q rate limited even after retry; status code %v", response.Request.URL.String(), response.StatusCode)
287-
case http.StatusMovedPermanently, http.StatusTemporaryRedirect, http.StatusServiceUnavailable:
287+
// 0 StatusCode means error on call side.
288+
case http.StatusMovedPermanently, http.StatusTemporaryRedirect, http.StatusServiceUnavailable, 0:
288289
if retries > 0 {
289290
break
290291
}

pkg/mdformatter/linktransformer/link_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func TestValidator_TransformDestination(t *testing.T) {
307307
))
308308
testutil.NotOk(t, err)
309309
testutil.Equals(t, fmt.Sprintf("%v: 2 errors: "+
310-
"%v:1: \"https://docs.gfoogle.com/drawings/d/e/2PACX-1vTBFK_cGMbxFpYcv/pub?w=960&h=720\" not accessible; status code 0: Get \"https://docs.gfoogle.com/drawings/d/e/2PACX-1vTBFK_cGMbxFpYcv/pub?w=960&h=720\": dial tcp: lookup docs.gfoogle.com: no such host; "+
310+
"%v:1: \"https://docs.gfoogle.com/drawings/d/e/2PACX-1vTBFK_cGMbxFpYcv/pub?w=960&h=720\" not accessible even after retry; status code 0: Get \"https://docs.gfoogle.com/drawings/d/e/2PACX-1vTBFK_cGMbxFpYcv/pub?w=960&h=720\": dial tcp: lookup docs.gfoogle.com: no such host; "+
311311
"%v:1: \"https://bwplotka.dev/does-not-exists\" not accessible; status code 404: Not Found", tmpDir+filePath, relDirPath+filePath, relDirPath+filePath), err.Error())
312312
})
313313

0 commit comments

Comments
 (0)