altimate-code icon indicating copy to clipboard operation
altimate-code copied to clipboard

fix: slugify returns empty string for non-ASCII skill/training names

Open anandgupta42 opened this issue 8 months ago • 1 comments

Problem

slugify() in training-import.ts strips all non-ASCII characters, returning an empty string for non-English content:

slugify("日本語スタイルガイド") // → ""
slugify("SQL Style Guide")      // → "sql-style-guide" ✓

This breaks training import for teams with Japanese, Chinese, Korean, or other non-Latin style guides.

Location

packages/opencode/src/altimate/tools/training-import.ts:225-231

Suggested Fix

Use transliterate or fall back to a hash-based name when the result is empty:

function slugify(text: string): string {
  const slug = text.toLowerCase()
    .replace(/[^a-z0-9\s-]/g, "")
    .replace(/\s+/g, "-")
    .replace(/^-+|-+$/g, "")
    .slice(0, 64)
  return slug || `entry-${Date.now()}`
}

Found During

PR #350 adversarial testing.

anandgupta42 avatar Mar 22 '26 16:03 anandgupta42

Fixed by PR #439 (commit 167d4a7d8) — slugify now uses NFKD normalization for accented characters and falls back to "untitled" for empty results.

kulvirgit avatar Mar 27 '26 00:03 kulvirgit