Title: Flaky unit-test collection: KeyError importing feast.infra.mcp_servers.mcp_server under pytest -n · Issue #6633 · feast-dev/feast · GitHub
Open Graph Title: Flaky unit-test collection: KeyError importing feast.infra.mcp_servers.mcp_server under pytest -n · Issue #6633 · feast-dev/feast
X Title: Flaky unit-test collection: KeyError importing feast.infra.mcp_servers.mcp_server under pytest -n · Issue #6633 · feast-dev/feast
Description: Expected Behavior make test-python-unit (pytest with -n / xdist) collects sdk/python/tests/unit/infra/feature_servers/test_mcp_server.py reliably. Current Behavior Intermittently, parallel unit-test collection fails on an xdist worker wh...
Open Graph Description: Expected Behavior make test-python-unit (pytest with -n / xdist) collects sdk/python/tests/unit/infra/feature_servers/test_mcp_server.py reliably. Current Behavior Intermittently, parallel unit-tes...
X Description: Expected Behavior make test-python-unit (pytest with -n / xdist) collects sdk/python/tests/unit/infra/feature_servers/test_mcp_server.py reliably. Current Behavior Intermittently, parallel unit-tes...
Opengraph URL: https://github.com/feast-dev/feast/issues/6633
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Flaky unit-test collection: KeyError importing feast.infra.mcp_servers.mcp_server under pytest -n","articleBody":"## Expected Behavior\n\n`make test-python-unit` (pytest with `-n` / xdist) collects `sdk/python/tests/unit/infra/feature_servers/test_mcp_server.py` reliably.\n\n## Current Behavior\n\nIntermittently, parallel unit-test collection fails on an xdist worker while importing the MCP server package, which aborts the whole session:\n\n```\nERROR collecting tests/unit/infra/feature_servers/test_mcp_server.py\nsdk/python/tests/unit/infra/feature_servers/test_mcp_server.py:8: in \u003cmodule>\n from feast.infra.mcp_servers.mcp_config import McpFeatureServerConfig\nsdk/python/feast/infra/mcp_servers/__init__.py:4: in \u003cmodule>\n from .mcp_server import add_mcp_support_to_app\n\u003cfrozen importlib._bootstrap>:946: in _load_unlocked\nE KeyError: 'feast.infra.mcp_servers.mcp_server'\n```\n\nThe tests pass in isolation, so this surfaces as a flaky `unit-test-python` job failure (seen recently on `unit-test-python (3.12, ubuntu-latest)`).\n\nRoot cause: `feast/infra/mcp_servers/mcp_server.py` imports `feast.feature_store.FeatureStore` at module load but uses it only for a type annotation on `add_mcp_support_to_app`. Because the package `__init__.py` eagerly imports `mcp_server`, importing `feast.infra.mcp_servers` pulls in the whole `feature_store` import graph. Under parallel collection that heavy import races with an in-progress `feature_store` import; the partially-initialized `mcp_server` module is cleaned up, and the outer import's `sys.modules.pop(\"feast.infra.mcp_servers.mcp_server\")` raises `KeyError`.\n\n## Steps to reproduce\n\nOrdering-dependent, so not reliably reproducible in isolation; it surfaces under the full parallel unit-test run (`make test-python-unit`, pytest `-n`). Isolated collection (`pytest --collect-only .../test_mcp_server.py`) always succeeds.\n\n### Specifications\n\n- Version: master (module unchanged through 0.65.x)\n- Platform: CI `unit-test-python (3.12, ubuntu-latest)`\n- Subsystem: `infra/mcp_servers`, unit-test collection\n\n## Possible Solution\n\nMove the `FeatureStore` import in `mcp_server.py` under `TYPE_CHECKING` (it is only a type annotation), so importing `mcp_server` no longer drags in the `feature_store` graph. I have a fix ready and will open a PR referencing this issue.\n","author":{"url":"https://github.com/larrysingleton007","@type":"Person","name":"larrysingleton007"},"datePublished":"2026-07-23T03:46:17Z","url":"https://github.com/feast-dev/feast/issues/6633"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:17c65a7f-8fc0-24f6-611d-1e2d211ab03d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D906:3CE002:2A02E8:3A8DE3:6AFE9814 |
| html-safe-nonce | f8495e4df9a422fa3377904a2cefa172ea63b6c7ac6b50c0f5b74cae6da61481 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTA2OjNDRTAwMjoyQTAyRTg6M0E4REUzOjZBRkU5ODE0IiwidmlzaXRvcl9pZCI6IjQzNTYwMDQ5ODUwMDQwMDUzOTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cd842985d859d58f88e0ebd6f5f0804cfd573ac0644db181dfaf3cf8995e769f |
| hovercard-subject-tag | issue:4955203063 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/feast-dev/feast/6633/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0e224b64b5f8c1f22d9946190597478a8d6a0c9ca75409d8174560172bc0bfe0/feast-dev/feast/issues/6633 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0e224b64b5f8c1f22d9946190597478a8d6a0c9ca75409d8174560172bc0bfe0/feast-dev/feast/issues/6633 |
| og:image:alt | Expected Behavior make test-python-unit (pytest with -n / xdist) collects sdk/python/tests/unit/infra/feature_servers/test_mcp_server.py reliably. Current Behavior Intermittently, parallel unit-tes... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | larrysingleton007 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86 |
| turbo-cache-control | no-preview |
| go-import | github.com/feast-dev/feast git https://github.com/feast-dev/feast.git |
| octolytics-dimension-user_id | 57027613 |
| octolytics-dimension-user_login | feast-dev |
| octolytics-dimension-repository_id | 161133770 |
| octolytics-dimension-repository_nwo | feast-dev/feast |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 161133770 |
| octolytics-dimension-repository_network_root_nwo | feast-dev/feast |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4a10310af51a1bfffbedc4fd81cb582acf0cb0ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width