Skip to content

Commit

Permalink
handle denied_authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Calcavecchia committed Jan 11, 2025
1 parent 3642186 commit 65684fa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/provider/providers/scaleway/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ func (p *Provider) Update(ctx context.Context, client *http.Client, ip netip.Add
}

if response.StatusCode != http.StatusOK {
var errorResponse struct {
Message string `json:"message"`
Type string `json:"type"`
}
if jsonErr := json.Unmarshal([]byte(s), &errorResponse); jsonErr == nil {
if errorResponse.Type == "denied_authentication" {
return netip.Addr{}, fmt.Errorf("%w: %s", errors.ErrAuth, errorResponse.Message)
}
}
return netip.Addr{}, fmt.Errorf("%w: %d: %s",
errors.ErrHTTPStatusNotValid, response.StatusCode, utils.ToSingleLine(s))
}
Expand Down

0 comments on commit 65684fa

Please sign in to comment.