Skip to content

Commit 39dd3cf

Browse files
committed
use header over body
1 parent 534d0ea commit 39dd3cf

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

codersdk/users.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io"
87
"net/http"
98
"strings"
109
"time"
@@ -193,15 +192,11 @@ func (c *Client) HasFirstUser(ctx context.Context) (bool, error) {
193192
defer res.Body.Close()
194193

195194
if res.StatusCode == http.StatusNotFound {
196-
b, err := io.ReadAll(res.Body)
197-
if err != nil {
198-
return false, err
199-
}
200195
// ensure we are talking to coder and not
201196
// some other service that returns 404
202-
isCoder := strings.Contains(string(b), "initial user has not been created")
203-
if !isCoder {
204-
return false, xerrors.Errorf("unexpected response: %s", string(b))
197+
v := res.Header.Get("X-Coder-Build-Version")
198+
if v == "" {
199+
return false, xerrors.Errorf("missing build version header, not a coder instance")
205200
}
206201

207202
return false, nil

0 commit comments

Comments
 (0)