Skip to content

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

Merged
mrgoonie merged 1 commit into
nextlevelbuilder:mainfrom
ia-abatista:fix/design-system-none-project-name
Jun 25, 2026
Merged

fix(scripts): guard persist_design_system against None project_name (#159)#388
mrgoonie merged 1 commit into
nextlevelbuilder:mainfrom
ia-abatista:fix/design-system-none-project-name

Conversation

@ia-abatista

Copy link
Copy Markdown
Contributor

What & why

persist_design_system crashes with AttributeError: 'NoneType' object has no attribute 'lower' (#159) when the design_system dict carries an explicit project_name of None:

project_name = design_system.get("project_name", "default")  # returns None when key is present-but-None
project_slug = project_name.lower().replace(' ', '-')        # 💥

dict.get(key, default) only substitutes the default for a missing key, not a present-but-None value — and generate(query, project_name=None) is the documented default, so a None reaches here easily.

Fix

Coalesce falsy values (None / "" / missing) to "default" before slugifying:

project_name = design_system.get("project_name") or "default"

Applied to both the source of truth (src/ui-ux-pro-max/scripts/) and the bundled cli/assets/ copy.

Verification

project_name=None          -> OK (no crash)
project_name=''            -> OK (no crash)
project_name='My Cool App' -> OK (no crash)
missing key                -> OK (no crash)

npm run check:assets passes (both copies in sync).

Scope

#159 also cited the core.py tokenize length filter ("search blindness"); that's already resolved on main (len(w) >= 2), so this PR targets only the remaining crash.

Supersedes #160 (same root cause; this version coalesces "" as well and keeps the two script copies in sync). Credit to @YangKuoshih for the original diagnosis and fix.

Closes #159

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 nextlevelbuilder#159 (core.py tokenize length filter) is
already resolved on main (`len(w) >= 2`), so this targets the remaining
crash only.

Closes nextlevelbuilder#159

Co-authored-by: YangKuoshih <155388493+YangKuoshih@users.noreply.github.com>
@mrgoonie mrgoonie merged commit 3a12b63 into nextlevelbuilder:main Jun 25, 2026
1 check passed
@ia-abatista ia-abatista deleted the fix/design-system-none-project-name branch June 25, 2026 08:44
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.

AttributeError Crash during File Persistence

2 participants