Skip to content

Fix empty project name prompt crash#471

Open
dipeshwalia wants to merge 1 commit into
TanStack:mainfrom
dipeshwalia:fix/project-name-undefined-input
Open

Fix empty project name prompt crash#471
dipeshwalia wants to merge 1 commit into
TanStack:mainfrom
dipeshwalia:fix/project-name-undefined-input

Conversation

@dipeshwalia

@dipeshwalia dipeshwalia commented Jun 9, 2026

Copy link
Copy Markdown

Summary

  • Treat undefined interactive project name input as an empty current-directory selection.
  • Allow the current-directory project-name helper to receive undefined prompt input.
  • Add regression coverage for the undefined prompt response.

Test plan

  • pnpm --filter @tanstack/create build
  • pnpm --filter @tanstack/cli test -- ui-prompts.test.ts
  • pnpm --filter @tanstack/cli build
  • Pre-commit ran pnpm build and pnpm test; visible output showed build, unit tests, and all 3 blocking e2e specs passed, but the Playwright runner hung after reporting the passing specs.

Summary by CodeRabbit

  • Bug Fixes

    • Resolved a crash that occurred when users left the project name prompt empty during interactive setup. The CLI now properly handles undefined or empty input by gracefully defaulting to the current directory, preventing application failures.
  • Tests

    • Added test coverage to verify proper handling of empty or skipped project name inputs in interactive mode.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 41b21808-1049-44ed-9b80-926812d571b8

📥 Commits

Reviewing files that changed from the base of the PR and between 6ea4076 and e2c22de.

📒 Files selected for processing (4)
  • .changeset/project-name-undefined-input.md
  • packages/cli/src/ui-prompts.ts
  • packages/cli/src/utils.ts
  • packages/cli/tests/ui-prompts.test.ts

📝 Walkthrough

Walkthrough

Fixes a crash when interactive project name prompts return undefined by adding null-safety to getProjectName, broadening isCurrentDirectoryProjectNameInput to accept optional input, and adding test coverage for the undefined case.

Changes

Handle Empty Project Name Input

Layer / File(s) Summary
Prompt input safe handling
packages/cli/src/ui-prompts.ts
getProjectName now returns a safely trimmed string using optional chaining and nullish coalescing (value?.trim() ?? '') instead of directly trimming value, preventing a runtime error when the prompt returns undefined.
Utility function signature update
packages/cli/src/utils.ts
isCurrentDirectoryProjectNameInput parameter type changes from name: string to name?: string, broadening the contract to handle optional input by normalizing undefined to empty string.
Test coverage and changelog
packages/cli/tests/ui-prompts.test.ts, .changeset/project-name-undefined-input.md
New test case verifies that when clack.text returns undefined, getProjectName resolves to an empty string; changelog documents the patch fix.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

  • TanStack/cli#466: Modifies getProjectName prompt behavior and corresponding test expectations in the same files.
  • TanStack/cli#458: The current PR's undefined/empty input handling directly supports the "current directory project creation" behavior this PR implements.
  • TanStack/cli#468: Addresses current-directory handling in project-name validation using the same prompt fix logic.

Poem

🐰 A prompt without an answer, oh what a fright,
but now we handle undefined with grace and might!
Empty becomes a current directory call,
no crash to fear, we've fixed it all. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix empty project name prompt crash' directly and clearly summarizes the main change: addressing a crash when the project name prompt receives undefined/empty input.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/cli/tests/ui-prompts.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/cli/tests/ui-prompts.test.ts


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dipeshwalia

Copy link
Copy Markdown
Author

cc @tannerlinsley fyi, I notice an issue while starting a new project. Maybe the fix is helpful. thanks

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.

1 participant