{"record":{"id":"f31bc055cd72be5f","repo":"derailed/k9s","slug":"re-description","errorCode":null,"errorMessage":"re.Description()","messagePattern":"re\\.Description\\(\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/json/validator.go","lineNumber":166,"sourceCode":"\n\ts, ok := v.schemas[k]\n\tif !ok {\n\t\treturn fmt.Errorf(\"no schema found for: %q\", k)\n\t}\n\tresult, err := gojsonschema.Validate(s, gojsonschema.NewGoLoader(m))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif result.Valid() {\n\t\treturn nil\n\t}\n\n\tslices.SortFunc(result.Errors(), func(a, b gojsonschema.ResultError) int {\n\t\treturn cmp.Compare(a.Description(), b.Description())\n\t})\n\tvar errs error\n\tfor _, re := range result.Errors() {\n\t\terrs = errors.Join(errs, errors.New(re.Description()))\n\t}\n\n\treturn errs\n}\n\nfunc (v *Validator) ValidateObj(k string, o any) error {\n\ts, ok := v.schemas[k]\n\tif !ok {\n\t\treturn fmt.Errorf(\"no schema found for: %q\", k)\n\t}\n\tresult, err := gojsonschema.Validate(s, gojsonschema.NewGoLoader(o))\n\tif err != nil {\n\t\treturn err\n\t}\n\tif result.Valid() {\n\t\treturn nil\n\t}\n","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/config/json/validator.go#L148-L184","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the full error chain — each joined line names the offending field and constraint; fix exactly those fields in your config","Diff your config against the shipped default schema/example for the current k9s version and remove renamed/obsolete keys","Validate after every k9s upgrade before launching, since schemas evolve between releases","If editing programmatically, keep types exactly as documented (e.g. booleans not 'true' strings)"],"exampleFix":"// before (skin.json uses a string where schema wants int)\n{\"body\": {\"fgColor\": \"cyan\"}, \"compact\": {\"bgColor\": 16711680}}\n\n// after (correct per schema)\n{\"body\": {\"fgColor\": \"cyan\"}, \"compact\": true}","handlingStrategy":"validation","validationCode":"// validate the document before using it\nif err := validator.Validate(\"skin\", jsonBytes); err != nil {\n    // show field-level messages to the user/editor\n}","typeGuard":null,"tryCatchPattern":"if err := validator.Validate(\"skin\", jsonBytes); err != nil {\n    // errors.Join chain: iterate and display each line\n    for _, e := range []error{err} { _ = e }\n    return fmt.Errorf(\"config invalid: %w\", err)\n}","preventionTips":["Run the validator in CI on checked-in k9s configs","Editor JSON-schema support for k9s config files catches typos pre-commit","After upgrading k9s, re-validate custom skins/configs before launch"],"tags":["json","schema-validation","config","k9s"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}