Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sdk/python/feast/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import json
import logging
import os
from datetime import datetime
from importlib.metadata import version as importlib_version
from pathlib import Path
Expand Down Expand Up @@ -462,6 +463,14 @@ def init_command(project_directory, minimal: bool, template: str, repo_path: str
if not project_directory:
project_directory = generate_project_name()

# When project_directory is an absolute or relative path (contains os.sep),
# treat it as the target directory with the basename as the project name.
# This allows `feast init /tmp/test` to work as expected.
if os.sep in project_directory:
if not repo_path:
repo_path = project_directory
project_directory = os.path.basename(project_directory)
Comment on lines +469 to +472
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Trailing slash in path argument produces empty project name

When a user runs feast init /tmp/test/ (with a trailing slash), os.path.basename("/tmp/test/") returns an empty string ''. This empty string passes the is_valid_name check at sdk/python/feast/repo_operations.py:577-581 (since an empty string doesn't start with _ or - and has no invalid characters), so init_repo proceeds to template feature_store.yaml with project: (empty project name), producing a corrupt configuration. The same issue occurs with any trailing-separator path like test/.

Suggested change
if os.sep in project_directory:
if not repo_path:
repo_path = project_directory
project_directory = os.path.basename(project_directory)
if os.sep in project_directory:
if not repo_path:
repo_path = project_directory
project_directory = os.path.basename(project_directory.rstrip(os.sep))
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


if minimal:
template = "minimal"

Expand Down