glab ci lint <URL> lints the response body even when the URL returns an error status
Summary
glab ci lint accepts a URL, but it ignores the HTTP status of the response.
If the URL returns 404 or any other error, the body of the error page is fed to
the lint endpoint, and the user gets a confusing syntax error about content
they never wrote instead of being told the URL could not be fetched.
Environment
- OS: Windows 11 - AMD64
- SHELL: bash
- TERM: Windows Terminal
- GLAB: built from
mainat 411aa39d (also present in v1.109.0)
Steps to reproduce
glab ci lint https://example.com/this-path-does-not-existWhat is the current bug behavior?
The response body is read and linted whatever the status code was, so the error page is validated as if it were a CI configuration. The reported problem describes the error page, not the user's mistake.
What is the expected correct behavior?
A non-2xx response should be reported as a failure to fetch the URL, including the status code, and nothing should be sent to the lint endpoint.
Possible fixes
Check the status code after the fetch and return an error before the body is passed on.