fix(scripts): guard persist_design_system against None project_name (#388)

persist_design_system crashed with AttributeError: 'NoneType' object has
no attribute 'lower' when the design_system dict carries an explicit
project_name of None (the default of generate(query, project_name=None)).
dict.get("project_name", "default") only substitutes the default for a
MISSING key, not a present-but-None value, so project_name.lower() blew
up.

Coalesce falsy values (None/""/missing) to "default" before slugifying.
Applied to both the source of truth and the bundled cli/assets copy.

The "search blindness" half of #159 (core.py tokenize length filter) is
already resolved on main (`len(w) >= 2`), so this targets the remaining
crash only.

Closes #159

Co-authored-by: YangKuoshih <155388493+YangKuoshih@users.noreply.github.com>
This commit is contained in:
Alexander 2026-06-25 04:43:33 -04:00 committed by GitHub
parent 57d9ba7989
commit 3a12b63bd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -573,8 +573,9 @@ def persist_design_system(design_system: dict, page: str = None, output_dir: str
"""
base_dir = Path(output_dir) if output_dir else Path.cwd()
# Use project name for project-specific folder
project_name = design_system.get("project_name", "default")
# Use project name for project-specific folder. Coalesce falsy values
# (missing key, explicit None, or "") so the .lower() below can't crash.
project_name = design_system.get("project_name") or "default"
project_slug = project_name.lower().replace(' ', '-')
design_system_dir = base_dir / "design-system" / project_slug

View File

@ -573,8 +573,9 @@ def persist_design_system(design_system: dict, page: str = None, output_dir: str
"""
base_dir = Path(output_dir) if output_dir else Path.cwd()
# Use project name for project-specific folder
project_name = design_system.get("project_name", "default")
# Use project name for project-specific folder. Coalesce falsy values
# (missing key, explicit None, or "") so the .lower() below can't crash.
project_name = design_system.get("project_name") or "default"
project_slug = project_name.lower().replace(' ', '-')
design_system_dir = base_dir / "design-system" / project_slug