refactor(mesi): split fetchUrl.go into fetch.go + ssrf.go#156
Merged
Conversation
s2x
commented
May 6, 2026
Contributor
Author
s2x
left a comment
There was a problem hiding this comment.
Two minor findings:
1. Removed inline comments in singleFetchUrlWithContext
A few explanatory comments were stripped from the function body that documented non-obvious decisions:
- Line ~74:
// Allowed host with private-IP bypass opt-in - use standard client without SSRF protection.— explains whyAllowPrivateIPsForAllowedHostsskips dial-time IP blocking - Line ~82:
// Note: When HTTPClient is provided, callers are responsible for setting appropriate timeouts and SSRF protection on the client. Use NewSSRFSafeTransport(config) to create a transport with dial-time private IP blocking.— important gotcha for external users - Line ~126:
// Use LimitReader to cap response size— explains the+1buffer onMaxResponseSize - Line ~134:
// No limit - backward compatibility— explains the zero-limit default behavior
Consider restoring these — they help future contributors understand the branching logic at a glance.
2. Redundant error wrapping at fetch.go:68
if err := isURLSafe(requestedURL, config); err != nil {
return "", false, fmt.Errorf("%w: %s", ErrSSRFBlocked, err.Error())
}isURLSafe already wraps its errors with ErrSSRFBlocked (see ssrf.go:49), so this creates ErrSSRFBlocked: ErrSSRFBlocked: ... chains. Harmless for errors.Is, but makes error messages unnecessarily verbose. Worth a follow-up cleanup — not blocking.
Otherwise the split looks clean, all tests pass, no API changes. LGTM.
071b73f to
add90c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mesi/fetchUrl.gointomesi/ssrf.go(SSRF validation) andmesi/fetch.go(HTTP fetching)mesi/fetchUrl_test.gointomesi/ssrf_test.goandmesi/fetch_test.gogo vetcleanCloses #120