moonD4rk/HackBrowserData · error

unknown browser kind: %d

Error message

unknown browser kind: %d

What it means

newBrowser builds a browser instance from a Config whose Kind field must be one of the known browser kinds. If Kind holds a value the switch doesn't handle (not a recognized Chromium/Firefox browser), construction fails with this error naming the numeric kind. It indicates a Config assembled with an invalid or out-of-range Kind.

Source

Thrown at browser/browser.go:160

			return nil, err
		}
		if b == nil {
			return nil, nil
		}
		return b, nil

	case types.Safari:
		b, err := safari.NewBrowser(cfg)
		if err != nil {
			return nil, err
		}
		if b == nil {
			return nil, nil
		}
		return b, nil

	default:
		return nil, fmt.Errorf("unknown browser kind: %d", cfg.Kind)
	}
}

// ListBrowsers returns sorted keys of all platform browsers.
func ListBrowsers() []string {
	var l []string
	for _, cfg := range platformBrowsers() {
		l = append(l, cfg.Key)
	}
	sort.Strings(l)
	return l
}

// Names returns a pipe-separated list of browser keys for CLI help text.
func Names() string {
	return strings.Join(ListBrowsers(), "|")
}

View on GitHub (pinned to 0503d04d7a)

Solutions

  1. Use a Kind constant defined by the browser package instead of a raw integer.
  2. Check the numeric value against the browser kind enum in browser/browser.go and pick a supported one.
  3. If the browser genuinely isn't supported, don't construct a Config for it — filter it out of discover results.
  4. Update the library if a new browser kind needs support in the switch.

Example fix

// before
cfg := browser.Config{Kind: 99, Name: "mybrowser"}
b, err := browser.NewBrowser(cfg)
// after
cfg := browser.Config{Kind: browser.Chrome, Name: "chrome"}
b, err := browser.NewBrowser(cfg)
Defensive patterns

Strategy: validation

Validate before calling

switch cfg.Kind {
case browser.Chrome, browser.Firefox /* supported kinds */ :
    // ok
default:
    return fmt.Errorf("unsupported browser kind %d", cfg.Kind)
}

Try / catch

b, err := browser.NewBrowser(cfg)
if err != nil && strings.HasPrefix(err.Error(), "unknown browser kind") {
    return nil, fmt.Errorf("kind %d unsupported in this build: %w", cfg.Kind, err)
}

Prevention

When it happens

Trigger: Calling newBrowser (directly or via discoverFromConfigs or BuildFromDump) with a Config whose Kind is an unregistered browser kind value — falls into the switch's default branch.

Common situations: Constructing browser.Config manually with a guessed Kind constant, a dump file declaring an unrecognized browser kind, or an enum added upstream but not handled in this build's switch.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of moonD4rk/HackBrowserData@0503d04d7a (2026-09-06). Data as JSON: /api/errors/5f7d0561ffd258f8. Report an issue: GitHub.