• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stacklok / toolhive-studio / 23743484240

30 Mar 2026 11:56AM UTC coverage: 60.372% (+1.3%) from 59.052%
23743484240

Pull #1783

github

web-flow
Merge f53b61be9 into d88b4bdbd
Pull Request #1783: feat(registry): handle authentication for registry server api

2974 of 5204 branches covered (57.15%)

219 of 251 new or added lines in 25 files covered. (87.25%)

4 existing lines in 4 files now uncovered.

4855 of 7764 relevant lines covered (62.53%)

125.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.59
/renderer/src/common/components/settings/registry/registry-errors-message.ts
1
import type { RegistryFormData } from './schema'
2
import { REGISTRY_FORM_TYPE } from './utils'
3

4
export const REGISTRY_WRONG_AUTH_TOAST =
5
  'Authentication failed. Check your Client ID'
4✔
6

7
export const REGISTRY_WRONG_ISSUER_TOAST =
8
  'Failed to configure OAuth. Check your Issuer URL.'
4✔
9

10
export const OIDC_DISCOVERY_PATTERN = 'OIDC discovery failed'
4✔
11

12
export const AUTH_FIELDS_REQUIRED_PATTERN =
13
  'auth.issuer and auth.client_id are required'
4✔
14

15
export const REGISTRY_AUTH_FIELDS_REQUIRED_TOAST =
16
  'Both Client ID and Issuer URL are required'
4✔
17

18
export const REGISTRY_AUTH_TOAST_ID = 'registry-auth-required'
4✔
19

20
const REGISTRY_AUTH_REQUIRED_CODE = 'registry_auth_required'
4✔
21
const REGISTRY_UNAVAILABLE_CODE = 'registry_unavailable'
4✔
22

23
/** Shown when GET /api/v1beta/registry fails with `code: registry_auth_required` (Registry Server API + OAuth). */
24
export const REGISTRY_AUTH_REQUIRED_UI_MESSAGE =
25
  'The configured registry server requires authentication. Please provide your Server URL, Client ID and Issuer URL to authenticate.'
4✔
26

27
/** Persistent toast shown when the app detects the registry auth error on startup. */
28
export const REGISTRY_AUTH_REQUIRED_TOAST_MESSAGE =
29
  'The configured registry requires authentication. The app will not work correctly until the registry is fixed or reset to default.'
4✔
30

31
/** Persistent toast shown when the app detects the registry is unreachable on startup. */
32
export const REGISTRY_UNAVAILABLE_TOAST_MESSAGE =
33
  'The configured registry is unreachable. The app will not work correctly until the registry URL is fixed or reset to default.'
4✔
34

35
/** Returns true if the error is a registry configuration issue that requires user action. */
36
export function isRegistryConfigError(error: unknown): boolean {
NEW
37
  return isRegistryAuthRequiredError(error) || isRegistryUnavailableError(error)
×
38
}
39

40
/** Returns the appropriate toast message for a registry config error. */
41
export function getRegistryErrorToastMessage(
42
  error: unknown
43
): string | undefined {
44
  if (isRegistryAuthRequiredError(error))
5✔
45
    return REGISTRY_AUTH_REQUIRED_TOAST_MESSAGE
3✔
46
  if (isRegistryUnavailableError(error))
2✔
47
    return REGISTRY_UNAVAILABLE_TOAST_MESSAGE
2✔
48
  return undefined
1✔
49
}
50

51
/** Fallback when GET /api/v1beta/registry fails for any other reason (or non-api_url types). */
52
const REGISTRY_LIST_LOAD_FALLBACK_MESSAGE =
53
  'Failed to load registry configuration. The registry source may be misconfigured or unavailable.'
4✔
54

55
function getErrorField(error: unknown, field: string): string | undefined {
56
  if (!error || typeof error !== 'object') return undefined
1,223✔
57
  return (error as Record<string, unknown>)[field] as string | undefined
59✔
58
}
59

60
export function isRegistryAuthRequiredError(error: unknown): boolean {
61
  return getErrorField(error, 'code') === REGISTRY_AUTH_REQUIRED_CODE
612✔
62
}
63

64
export function isRegistryUnavailableError(error: unknown): boolean {
65
  return getErrorField(error, 'code') === REGISTRY_UNAVAILABLE_CODE
609✔
66
}
67

68
/**
69
 * Detects structured errors from GET /api/v1beta/registry when the backend
70
 * requires OAuth. Returns our UI copy — not the raw API `message` (e.g. no CLI hints).
71
 */
72
export function getRegistryAuthRequiredMessage(
73
  error: unknown
74
): string | undefined {
75
  if (isRegistryAuthRequiredError(error)) {
299✔
76
    return REGISTRY_AUTH_REQUIRED_UI_MESSAGE
4✔
77
  }
78
  return undefined
295✔
79
}
80

81
/** Shown in the registry error page when the upstream registry is unreachable. */
82
export const REGISTRY_UNAVAILABLE_UI_MESSAGE =
83
  'The upstream registry is unreachable or the API URL is misconfigured. Please check your Registry Server API URL in the settings.'
4✔
84

85
export const REGISTRY_UNAVAILABLE_SOURCE_MESSAGE =
86
  'The Registry Server API URL is not correct. Make sure it points to a valid MCP Registry API endpoint.'
4✔
87

88
/** Extracts the misconfigured registry URL from the raw API error message. */
89
export function getRegistryUnavailableUrl(error: unknown): string | undefined {
90
  if (!isRegistryUnavailableError(error)) return undefined
299✔
91
  const raw = getErrorField(error, 'message') ?? ''
2!
92
  const match = raw.match(/upstream registry at (\S+) is unavailable/)
299✔
93
  return match?.[1]
299✔
94
}
95

96
/**
97
 * Message under the registry source field when GET /api/v1beta/registry failed.
98
 * Uses OAuth-specific copy only for Registry Server API when `registryAuthRequiredMessage` is set.
99
 */
100
export function resolveRegistryListLoadErrorMessage(
101
  registryType: RegistryFormData['type'],
102
  registryAuthRequiredMessage?: string
103
): string {
104
  if (
4✔
105
    registryType === REGISTRY_FORM_TYPE.API_URL &&
8✔
106
    registryAuthRequiredMessage
107
  ) {
108
    return registryAuthRequiredMessage
3✔
109
  }
110
  return REGISTRY_LIST_LOAD_FALLBACK_MESSAGE
1✔
111
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc