Skip to content

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

Description

@anandgupta42

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions