feast-dev / feast-dev/feast

Flaky test: test_cli_apply_duplicated_featureview_names fails with empty output on subprocess timeout

Open
#6,417 5 comments 0 reactions 1 assignee Claimed by @obielin View on GitHub
good first issue starter-ticket
Dominant language
Python
Stars
7.3k
Forks
1.4k
Avg merge
1d 21h
Merged PRs (30d)
15

Description

## Summary

`test_cli_apply_duplicated_featureview_names` is intermittently failing in CI (observed on parallel pytest-xdist workers):

```
FAILED sdk/python/tests/unit/cli/test_cli_apply_duplicates.py::test_cli_apply_duplicated_featureview_names
AssertionError: assert (-1 != 0 and b'Feature view names must be case-insensitively unique' in b'')
```

The return code `-1` and empty output `b''` indicate the subprocess timed out and was killed before producing any output.

## Root Cause

Duplicate feature view name detection happens too late in the pipeline — inside `store.plan()` / `store.apply()` via `_validate_feature_views()` in `feature_store.py`. By that point, `FeatureStore` and its dependencies (Dask, registry, provider) have already been initialized.

The call chain is:

1. CLI `apply_total_command` calls `apply_total()`, which calls `_get_repo_contents()` (parses repo), then `_get_store_and_registry()` (creates FeatureStore), then `apply_total_with_repo_instance()`, then `store.plan()`, then `_validate_all_feature_views()`, which finally raises `ConflictingFeatureViewNames`.
2. The CLI only catches `FeastProviderLoginError`, so `ConflictingFeatureViewNames` propagates as an **unhandled exception** (raw traceback).
3. During process shutdown, slow atexit handlers (Dask thread pool, PySpark JVM) can block indefinitely.
4. The test helper `CliRunner.run_with_output()` has a 60s timeout — when exceeded, it sends SIGKILL and the output is lost.

This creates two compounding problems:
- **The error is raised too late** — after heavy initialization that can trigger slow cleanup on exit
- **The CLI does not handle the error** — producing a traceback instead of a clean message, and not exiting promptly

## Proposed Fix

1. **Detect duplicate names at parse time in `parse_repo()`** (repo_operations.py): Track feature view names (across FeatureView, BatchFeatureView, StreamFeatureView, OnDemandFeatureView) and data source names during collection. Raise `ConflictingFeatureViewNames` / `DataSourceRepeatNamesException` immediately when a collision is found — before FeatureStore or any heavy dependencies are initialized.

2. **Catch `FeastError` in CLI plan/apply commands** (cli/cli.py): Add `except FeastError` handlers (after the existing `FeastProviderLoginError` handler) to print a clean error message and exit with code 1, instead of letting validation errors propagate as unhandled tracebacks.

## Environment

- Observed on macOS CI runners with pytest-xdist parallel execution ([gw2])
- Python 3.11.9

## Affected Tests

- `test_cli_apply_duplicated_featureview_names`
- `test_cli_apply_duplicate_data_source_names` (same pattern, same risk)
- `test_cli_apply_duplicated_featureview_names_multiple_py_files` (same pattern, same risk)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.