From 3a12b63bd8537cf3dd0127b9a464ce948f908f41 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 25 Jun 2026 04:43:33 -0400 Subject: [PATCH] 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> --- cli/assets/scripts/design_system.py | 5 +++-- src/ui-ux-pro-max/scripts/design_system.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/assets/scripts/design_system.py b/cli/assets/scripts/design_system.py index d3152e5..339aaba 100644 --- a/cli/assets/scripts/design_system.py +++ b/cli/assets/scripts/design_system.py @@ -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 diff --git a/src/ui-ux-pro-max/scripts/design_system.py b/src/ui-ux-pro-max/scripts/design_system.py index d3152e5..339aaba 100644 --- a/src/ui-ux-pro-max/scripts/design_system.py +++ b/src/ui-ux-pro-max/scripts/design_system.py @@ -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