charmbracelet/crush · error
failed to fetch provider from Hyper: %w
Error message
failed to fetch provider from Hyper: %w
What it means
UpdateHyper fetches the Hyper provider definition either from a URL via the Hyper client's Get method or from a local JSON file. This error wraps a failure of client.Get against the Hyper endpoint at pathOrURL: network failure, non-2xx response, or invalid response payload. Without it, the Hyper provider cannot be registered.
Source
Thrown at internal/config/provider.go:129
type HyperTokenRefresher func(context.Context) error
// UpdateHyper updates the Hyper provider information from a specified URL.
func UpdateHyper(pathOrURL string) error {
var provider catwalk.Provider
pathOrURL = cmp.Or(pathOrURL, hyper.BaseURL())
switch {
case pathOrURL == "embedded":
provider = hyper.Embedded()
case strings.HasPrefix(pathOrURL, "http://") || strings.HasPrefix(pathOrURL, "https://"):
client := realHyperClient{
baseURL: pathOrURL,
resolveKey: func() string { return resolveHyperAPIKey(nil) },
}
var err error
provider, err = client.Get(context.Background(), "")
if err != nil {
return fmt.Errorf("failed to fetch provider from Hyper: %w", err)
}
default:
content, err := os.ReadFile(pathOrURL)
if err != nil {
return fmt.Errorf("failed to read file: %w", err)
}
if err := json.Unmarshal(content, &provider); err != nil {
return fmt.Errorf("failed to unmarshal provider data: %w", err)
}
}
if err := newCache[catwalk.Provider](cachePathFor("hyper")).Store(provider); err != nil {
return fmt.Errorf("failed to save Hyper provider to cache: %w", err)
}
slog.Info("Hyper provider updated successfully", "from", pathOrURL, "to", cachePathFor("hyper"))
return nil
}View on GitHub (pinned to 7944b8e522)
Solutions
- Verify the base URL and that the service is up (`curl -v <baseURL>`).
- Export the API key env var expected by resolveHyperAPIKey.
- Check proxy settings (HTTPS_PROXY) and DNS resolution.
- Fall back to supplying the provider as a local JSON file path instead of a URL.
Example fix
// before
err := config.UpdateHyper("http://hyper.internal:8080")
// after
os.Setenv("HYPER_API_KEY", key) // ensure key resolves
err := config.UpdateHyper("https://hyper.internal:8080") Defensive patterns
Strategy: try-catch
Validate before calling
resp, err := http.Get(baseURL + "/health")
if err != nil || resp.StatusCode != http.StatusOK {
return fmt.Errorf("hyper endpoint unreachable before UpdateHyper: %v", err)
}
if os.Getenv("HYPER_API_KEY") == "" {
return errors.New("HYPER_API_KEY not set; UpdateHyper will fail auth")
} Try / catch
provider, err := client.Get(ctx, "")
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) || errors.Is(err, context.DeadlineExceeded) {
slog.Warn("hyper fetch failed; will retry with backoff", "err", err)
}
return fmt.Errorf("failed to fetch provider from Hyper: %w", err)
} Prevention
- Health-check the Hyper base URL before configuring it.
- Export the API key env var resolveHyperAPIKey expects before startup.
- Add retries with backoff for transient network failures.
- Keep a local JSON fallback file for offline environments.
When it happens
Trigger: Calling config.UpdateHyper with an http(s) pathOrURL when the Hyper endpoint is unreachable, returns an error status, requires an API key that resolveHyperAPIKey cannot find, or the context is cancelled.
Common situations: Wrong Hyper base URL in config; missing HYPER_API_KEY-style env var; Hyper service outage; corporate proxy blocking the request.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- failed to fetch providers from Catwalk: %w
- Crush was unable to fetch updated information from Hyper: %w
- failed to refetch Hyper provider: %w
- empty providers list from catwalk
- failed to download from URL: %w
AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29).
Data as JSON: /api/errors/2139f2eede10f89b.
Report an issue: GitHub.