matryer/xbar · error
unknown xbar.var type: %s
Error message
unknown xbar.var type: %s
What it means
parsePluginVar only supports a fixed set of xbar.var types (e.g. string, number, select, checkbox). If the var declaration uses an unrecognized type keyword, the parser falls into the default branch and returns errors.Errorf("unknown xbar.var type: %s", v.Type).
Source
Thrown at pkg/metadata/plugin_metadata.go:444
src: s,
err: errors.New("malformed xbar.var format (empty select options)"),
}
}
defaultFound := false
for _, val := range v.Options {
if val == v.Default {
defaultFound = true
break
}
}
if !defaultFound {
return v, errParse{
src: s,
err: errors.New("malformed xbar.var format (default not in select options)"),
}
}
default: // invalid type
return v, errors.Errorf("unknown xbar.var type: %s", v.Type)
}
return v, nil
}
type errMissingMetadata string
func (e errMissingMetadata) Error() string {
return fmt.Sprintf("missing <%[1]s></%[1]s>", string(e))
}
type errParse struct {
src string
err error
}
func (e errParse) Error() string {
if e.src != "" {
return fmt.Sprintf("%s: %q", e.err, e.src)View on GitHub (pinned to d624239058)
Solutions
- Change the var type keyword to a supported one (string, number, select, checkbox)
- Fix the typo in the type name in the xbar.var comment
- Check xbar plugin API docs for the list of valid var types
Example fix
// before // <xbar.var>integer(VAR_COUNT=5): How many</xbar.var> // after // <xbar.var>number(VAR_COUNT=5): How many</xbar.var>
Defensive patterns
Strategy: validation
Validate before calling
// before Parse: check var type keywords
valid := map[string]bool{"string": true, "number": true, "select": true, "checkbox": true}
re := regexp.MustCompile(`<xbar\.var>(\w+)\(`)
for _, m := range re.FindAllStringSubmatch(pluginSrc, -1) {
if !valid[m[1]] {
return fmt.Errorf("unsupported xbar.var type %q", m[1])
}
} Try / catch
// Go: detect the plain error text
if _, err := meta.Parse(src); err != nil {
if strings.Contains(err.Error(), "unknown xbar.var type") {
return fmt.Errorf("fix plugin metadata: %w", err)
}
return err
} Prevention
- Use only documented xbar.var types: string, number, select, checkbox
- Add a metadata linter to CI
- Never invent type aliases like int or bool
When it happens
Trigger: Calling Parse on plugin source whose `<xbar.var>TYPE(...)</xbar.var>` declaration uses a misspelled or unsupported type, e.g. `<xbar.var>str(VAR_X="v")</xbar.var>` or `<xbar.var>integer(VAR_N=5)</xbar.var>`.
Common situations: Typo in the type keyword; using a type from a different plugin ecosystem's schema; inventing a type (int, bool) that xbar metadata does not define.
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
- malformed xbar.var format (default not in select options)
- no plugin files
- malformed parameters: missing equals
- metadata.Parse
- missing xbar.title
AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02).
Data as JSON: /api/errors/435195fb3bad236a.
Report an issue: GitHub.