Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. The format

## Table of Contents

- [1.2.10 - 2025-09-16](#1210---2025-09-16)
- [1.2.9 - 2025-09-07](#129---2025-09-07)
- [1.2.8 - 2025-08-07](#128---2025-08-07)
- [1.2.7 - 2025-08-05](#127---2025-08-05)
Expand Down Expand Up @@ -44,6 +45,15 @@ All notable changes to this project will be documented in this file. The format
- [1.1.0 - 2024-08-19](#110---2024-08-19)
- [1.0.0 - 2024-06-06](#100---2024-06-06)

## [1.2.10] - 2025-09-16

### Added
- New error type `ErrHTTPServerFailedToAuthenticate` for authentication failures

### Changed
- Updated error return to include the new error type using `errors.Join()`
- Replaced string-based error checking with proper `errors.Is()` type checking

## [1.2.9] - 2025-09-07

### Added
Expand Down
2 changes: 1 addition & 1 deletion auth/clients/authhttp/authhttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func (a *AuthFetch) Fetch(ctx context.Context, urlStr string, config *Simplified
err error
}{resp, retryErr}
return
} else if strings.Contains(err.Error(), "HTTP server failed to authenticate") {
} else if errors.Is(err, transports.ErrHTTPServerFailedToAuthenticate) {
// Fall back to regular HTTP request
resp, fallbackErr := a.handleFetchAndValidate(urlStr, config, peerToUse)
responseChan <- struct {
Expand Down
7 changes: 5 additions & 2 deletions auth/transports/errors.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Package transports provides implementations of the auth.Transport interface
package transports

import "errors"
import (
"errors"
)

// Common errors for all transports
var (
// ErrNoHandlerRegistered is returned when trying to send a message without registering an OnData handler
ErrNoHandlerRegistered = errors.New("no OnData handler registered")
ErrNoHandlerRegistered = errors.New("no OnData handler registered")
ErrHTTPServerFailedToAuthenticate = errors.New("HTTP server failed to authenticate")
)
2 changes: 1 addition & 1 deletion auth/transports/simplified_http_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (t *SimplifiedHTTPTransport) authMessageFromNonGeneralMessageResponse(resp

if resp.StatusCode < 200 || resp.StatusCode >= 300 {
body, _ := io.ReadAll(resp.Body)
return responseMsg, fmt.Errorf("request failed with status %d: %s", resp.StatusCode, string(body))
return responseMsg, errors.Join(ErrHTTPServerFailedToAuthenticate, fmt.Errorf("request failed with status %d: %s", resp.StatusCode, string(body)))
}

if resp.ContentLength == 0 {
Expand Down
Loading