Skip to content

fix: support absolute paths in feast init CLI argument#6146

Open
joaquinhuigomez wants to merge 1 commit intofeast-dev:masterfrom
joaquinhuigomez:fix/cli-init-path-argument
Open

fix: support absolute paths in feast init CLI argument#6146
joaquinhuigomez wants to merge 1 commit intofeast-dev:masterfrom
joaquinhuigomez:fix/cli-init-path-argument

Conversation

@joaquinhuigomez
Copy link

@joaquinhuigomez joaquinhuigomez commented Mar 24, 2026

Summary

Fixes #6134

feast init /tmp/test currently fails with:

Error: Invalid value for PROJECT_DIRECTORY: Name should be alphanumeric values, underscores, and hyphens but not start with an underscore or hyphen

The root cause is that when a path (containing /) is passed as the PROJECT_DIRECTORY argument, the entire string (e.g. /tmp/test) is validated as a project name. Since slashes aren't valid in project names, validation fails.

Fix

When PROJECT_DIRECTORY contains a path separator, the CLI now:

  1. Uses the full path as repo_path (the target directory)
  2. Extracts the basename as the project name (e.g. test from /tmp/test)

This makes feast init /tmp/test behave equivalently to feast init test --repo-path /tmp/test, which already works correctly.

If --repo-path is explicitly provided alongside a path argument, the explicit --repo-path takes precedence.

Test plan

  • feast init /tmp/test creates the repo at /tmp/test with project name test
  • feast init myproject still works as before (no path separator, no behavior change)
  • feast init /tmp/test --repo-path /other/path uses /other/path as the directory and test as the name

Open with Devin

@joaquinhuigomez joaquinhuigomez requested a review from a team as a code owner March 24, 2026 21:19
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +469 to +472
if os.sep in project_directory:
if not repo_path:
repo_path = project_directory
project_directory = os.path.basename(project_directory)
Copy link
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.

When a user runs `feast init /tmp/test`, the path argument is now
correctly parsed: the directory path is used as repo_path and the
basename is used as the project name. Previously, the entire path
was validated as a project name, which failed because slashes are
not valid in project names.

Fixes feast-dev#6134

Signed-off-by: Joaquin Hui Gomez <132194176+joaquinhuigomez@users.noreply.github.com>
@joaquinhuigomez joaquinhuigomez force-pushed the fix/cli-init-path-argument branch from d58bb9e to 2644985 Compare March 27, 2026 12:26
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.

feast init /tmp/test # does not work

1 participant