From af34829f38fc101a09e23424f37e40d4e63b408d Mon Sep 17 00:00:00 2001 From: Maista <131594657+Maista6969@users.noreply.github.com> Date: Mon, 2 Jun 2025 07:47:03 +0200 Subject: [PATCH] Stash box validation bugfix (#5831) * Remove accidental copypaste error The apiKey ref was accidentally associated with the max_requests_per_minute field which made the "Test Credentials" button error out every time * Fix error messages in stash-box validation The message from err.Error() can start with any number of errors like NetworkError so we can check for substrings instead --- internal/api/resolver_query_configuration.go | 15 ++++++++------- .../components/Settings/StashBoxConfiguration.tsx | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/api/resolver_query_configuration.go b/internal/api/resolver_query_configuration.go index 81f39a7c5..cfa22720b 100644 --- a/internal/api/resolver_query_configuration.go +++ b/internal/api/resolver_query_configuration.go @@ -249,18 +249,19 @@ func (r *queryResolver) ValidateStashBoxCredentials(ctx context.Context, input c if valid { status = fmt.Sprintf("Successfully authenticated as %s", user.Me.Name) } else { + errorStr := strings.ToLower(err.Error()) switch { - case strings.Contains(strings.ToLower(err.Error()), "doctype"): + case strings.Contains(errorStr, "doctype"): // Index file returned rather than graphql status = "Invalid endpoint" - case strings.Contains(err.Error(), "request failed"): + case strings.Contains(errorStr, "request failed"): status = "No response from server" - case strings.HasPrefix(err.Error(), "invalid character") || - strings.HasPrefix(err.Error(), "illegal base64 data") || - err.Error() == "unexpected end of JSON input" || - err.Error() == "token contains an invalid number of segments": + case strings.Contains(errorStr, "invalid character") || + strings.Contains(errorStr, "illegal base64 data") || + strings.Contains(errorStr, "unexpected end of json input") || + strings.Contains(errorStr, "token contains an invalid number of segments"): status = "Malformed API key." - case err.Error() == "" || err.Error() == "signature is invalid": + case strings.Contains(errorStr, "signature is invalid"): status = "Invalid or expired API key." default: status = fmt.Sprintf("Unknown error: %s", err) diff --git a/ui/v2.5/src/components/Settings/StashBoxConfiguration.tsx b/ui/v2.5/src/components/Settings/StashBoxConfiguration.tsx index cab8a4e76..dbc370eeb 100644 --- a/ui/v2.5/src/components/Settings/StashBoxConfiguration.tsx +++ b/ui/v2.5/src/components/Settings/StashBoxConfiguration.tsx @@ -139,7 +139,6 @@ export const StashBoxModal: React.FC = ({ value, close }) => { max_requests_per_minute: parseInt(e.currentTarget.value), }) } - ref={apiKey} />