Skip to content

fix(skills): guard the skill editor against null columns - #18

Merged
squarezw merged 1 commit into
mainfrom
fix/skill-editor-null-fields
Aug 18, 2026
Merged

fix(skills): guard the skill editor against null columns#18
squarezw merged 1 commit into
mainfrom
fix/skill-editor-null-fields

Conversation

@squarezw

Copy link
Copy Markdown
Owner

Pairs with ragent-service#85.

Opening an imported skill's detail page blanked the whole page:

TypeError: Cannot read properties of null (reading 'trim')
  at SkillEditor.useMemo[payload] (SkillEditor.tsx:121)

Cause

SkillEditor assigns those fields in two places, and only one had a fallback:

const [displayName, setDisplayName] = useState(skill?.display_name || "");  // ✅

setDisplayName(skill.display_name);   // ❌ backfill once the skill loads

A NULL went straight into state, and the next name.trim() threw.

Why it stayed hidden until now

Manually created skills store empty strings in those columns. The first source that genuinely stored NULL was the importer — when SKILL.md's frontmatter omits display_name, it is deliberately left empty for the user to fill — so the defect surfaced the day that shipped.

neodata-financial-search imported fine earlier because its frontmatter happens to carry a display_name; kie-media-gen's does not.

Fixed on both sides

The importer now writes empty strings too (ragent-service#85), but the guard belongs here regardless: the editor should not depend on every writer agreeing how to spell "not filled". And the writer should not add a second spelling. Fixing only one side leaves either the next writer or the next reader exposed.

Test

Asserts both the useState initialisers and the backfill carry a fallback. The two correspond to entering the page directly versus clicking through from the list, so fixing one path leaves the other broken.

Source-level assertions rather than a render test — this repo has no jsdom, and the rule ("every setter needs a fallback") is exactly the kind that suits enumerating the setters.

Verified by reverting each guard in turn; both mutations fail the test.

287 passing, tsc non-TS5097 errors unchanged at 112.

🤖 Generated with Claude Code

Opening an imported skill's detail page blanked the whole page:

    TypeError: Cannot read properties of null (reading 'trim')
      at SkillEditor.useMemo[payload]

The `useState` initialisers already had `|| ""`. The backfill that runs once
the skill finishes loading did not, so a NULL went straight into state and the
next `name.trim()` threw.

It stayed hidden because manually created skills store empty strings in those
columns. The first source that genuinely stored NULL was the importer — when
SKILL.md's frontmatter omits `display_name`, it is left empty on purpose for
the user to fill — and it surfaced this the day it shipped.

The importer now writes empty strings too, but the guard belongs here
regardless: the editor should not depend on every writer agreeing about how to
spell "not filled".

Test asserts both the initialisers and the backfill carry a fallback — the two
correspond to entering the page directly versus clicking through from the
list, so fixing only one leaves the other path broken. Verified by reverting
each guard in turn.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@squarezw
squarezw merged commit d19d1c6 into main Aug 18, 2026
1 check passed
@squarezw
squarezw deleted the fix/skill-editor-null-fields branch August 18, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant