Skip to content

Commit af34829

Browse files
authored
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
1 parent 155c4ec commit af34829

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

internal/api/resolver_query_configuration.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,19 @@ func (r *queryResolver) ValidateStashBoxCredentials(ctx context.Context, input c
249249
if valid {
250250
status = fmt.Sprintf("Successfully authenticated as %s", user.Me.Name)
251251
} else {
252+
errorStr := strings.ToLower(err.Error())
252253
switch {
253-
case strings.Contains(strings.ToLower(err.Error()), "doctype"):
254+
case strings.Contains(errorStr, "doctype"):
254255
// Index file returned rather than graphql
255256
status = "Invalid endpoint"
256-
case strings.Contains(err.Error(), "request failed"):
257+
case strings.Contains(errorStr, "request failed"):
257258
status = "No response from server"
258-
case strings.HasPrefix(err.Error(), "invalid character") ||
259-
strings.HasPrefix(err.Error(), "illegal base64 data") ||
260-
err.Error() == "unexpected end of JSON input" ||
261-
err.Error() == "token contains an invalid number of segments":
259+
case strings.Contains(errorStr, "invalid character") ||
260+
strings.Contains(errorStr, "illegal base64 data") ||
261+
strings.Contains(errorStr, "unexpected end of json input") ||
262+
strings.Contains(errorStr, "token contains an invalid number of segments"):
262263
status = "Malformed API key."
263-
case err.Error() == "" || err.Error() == "signature is invalid":
264+
case strings.Contains(errorStr, "signature is invalid"):
264265
status = "Invalid or expired API key."
265266
default:
266267
status = fmt.Sprintf("Unknown error: %s", err)

ui/v2.5/src/components/Settings/StashBoxConfiguration.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ export const StashBoxModal: React.FC<IStashBoxModal> = ({ value, close }) => {
139139
max_requests_per_minute: parseInt(e.currentTarget.value),
140140
})
141141
}
142-
ref={apiKey}
143142
/>
144143
<div className="sub-heading">
145144
<FormattedMessage

0 commit comments

Comments
 (0)