Skip to content

Commit

Permalink
feat: verbose error for instance urls with api suffix (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymek authored Sep 17, 2024
1 parent 68c40a0 commit 10d3854
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/src/http/unleash_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@ impl UnleashClient {
&self,
request: ValidateTokensRequest,
) -> EdgeResult<Vec<EdgeToken>> {
let check_api_suffix = || {
let base_url = self.urls.base_url.to_string();
if base_url.ends_with("/api") || base_url.ends_with("/api/") {
info!("Try passing the instance URL without '/api'.");
}
};

let result = self
.backing_client
.post(self.urls.edge_validate_url.to_string())
Expand All @@ -440,6 +447,7 @@ impl UnleashClient {
.await
.map_err(|e| {
info!("Failed to validate tokens: [{e:?}]");
check_api_suffix();
EdgeError::EdgeTokenError
})?;
match result.status() {
Expand Down Expand Up @@ -473,6 +481,7 @@ impl UnleashClient {
self.urls.edge_validate_url.to_string(),
s
);
check_api_suffix();
Err(EdgeError::TokenValidationError(
reqwest::StatusCode::from_u16(s.as_u16()).unwrap(),
))
Expand Down

0 comments on commit 10d3854

Please sign in to comment.