cloudflared icon indicating copy to clipboard operation
cloudflared copied to clipboard

fix typo in errcheck for response parsing logic in CreateTunnel routine

Open sivukhin opened this issue 2 years ago • 0 comments

I ran govanish linter against cloudflared repo and it found suspicious issue: compiler eliminates err check in CreateTunnel function:

...
case http.StatusOK:
	var tunnel TunnelWithToken
	if serdeErr := parseResponse(resp.Body, &tunnel); err != nil {
		return nil, serdeErr
	}
	return &tunnel, nil
...
2024/01/05 11:53:01 it seems like your code vanished from compiled binary: func=[CreateTunnel], file=[/home/sivukhin/code/cloudflared/cfapi/tunnel.go], lines=[97-97], snippet:
	return nil, serdeErr

Indeed, this is bug - serdeErr should be checked instead of err.

This PR fixes the code.

sivukhin avatar Jan 05 '24 07:01 sivukhin