derailed/k9s · error

re.Description()

Error message

re.Description()

What it means

The recorded message 're.Description()' is the literal expression at internal/config/json/validator.go:166 — the runtime message is dynamic: each gojsonschema ResultError description is joined into one error. Validate(schema, doc) failed schema validation, so callers see the underlying constraint text (e.g. 'name: Invalid type. Expected: string, given: integer', 'tabs: Additional property foo is not allowed'). This is k9s validating its skin/config JSON payloads against bundled schemas.

Source

Thrown at internal/config/json/validator.go:166

	s, ok := v.schemas[k]
	if !ok {
		return fmt.Errorf("no schema found for: %q", k)
	}
	result, err := gojsonschema.Validate(s, gojsonschema.NewGoLoader(m))
	if err != nil {
		return err
	}
	if result.Valid() {
		return nil
	}

	slices.SortFunc(result.Errors(), func(a, b gojsonschema.ResultError) int {
		return cmp.Compare(a.Description(), b.Description())
	})
	var errs error
	for _, re := range result.Errors() {
		errs = errors.Join(errs, errors.New(re.Description()))
	}

	return errs
}

func (v *Validator) ValidateObj(k string, o any) error {
	s, ok := v.schemas[k]
	if !ok {
		return fmt.Errorf("no schema found for: %q", k)
	}
	result, err := gojsonschema.Validate(s, gojsonschema.NewGoLoader(o))
	if err != nil {
		return err
	}
	if result.Valid() {
		return nil
	}

View on GitHub (pinned to 2d3ccc6ba2)

Solutions

  1. Read the full error chain — each joined line names the offending field and constraint; fix exactly those fields in your config
  2. Diff your config against the shipped default schema/example for the current k9s version and remove renamed/obsolete keys
  3. Validate after every k9s upgrade before launching, since schemas evolve between releases
  4. If editing programmatically, keep types exactly as documented (e.g. booleans not 'true' strings)

Example fix

// before (skin.json uses a string where schema wants int)
{"body": {"fgColor": "cyan"}, "compact": {"bgColor": 16711680}}

// after (correct per schema)
{"body": {"fgColor": "cyan"}, "compact": true}
Defensive patterns

Strategy: validation

Validate before calling

// validate the document before using it
if err := validator.Validate("skin", jsonBytes); err != nil {
    // show field-level messages to the user/editor
}

Try / catch

if err := validator.Validate("skin", jsonBytes); err != nil {
    // errors.Join chain: iterate and display each line
    for _, e := range []error{err} { _ = e }
    return fmt.Errorf("config invalid: %w", err)
}

Prevention

When it happens

Trigger: Calling Validator.Validate with a JSON document (skin config, alias config, etc.) that violates its schema: wrong field type, unknown extra property, missing required key, bad enum value. Sorted by description for deterministic output.

Common situations: Hand-edited skin.yaml/json with typos or renamed keys after a k9s upgrade (schema gained/renamed fields); view/config files from an older k9s version revalidated by a newer one; extra keys the schema disallows because additionalProperties is false.

Related errors


AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15). Data as JSON: /api/errors/f31bc055cd72be5f. Report an issue: GitHub.