Skip to content

fix(sync): restore the DS client factory default after CLI-13 - #770

Closed
Matovidlo wants to merge 1 commit into
mainfrom
martinvasko-fix-sync-service-ds-client-factory-import
Closed

Matovidlo wants to merge 1 commit into
mainfrom
martinvasko-fix-sync-service-ds-client-factory-import

Conversation

@Matovidlo

Copy link
Copy Markdown
Contributor

Summary

  • Fixes main's own tip being CI-red (check, test (3.12), and the Windows wheel-build job all failing) since PR feat: accept browser-login (session) tokens for the commands whose backend supports them (CLI-13) #759 (CLI-13, session-token support) merged.
  • Root cause: PR feat: accept browser-login (session) tokens for the commands whose backend supports them (CLI-13) #759 replaced data_app_service.py's module-level _default_ds_client_factory with make_session_aware_client_factory(config_store, DataScienceClient), but left sync_service.py importing the now-removed name. Any code path that imports keboola_agent_cli.cli (almost the entire CLI) or the FastAPI server app failed at import time with ImportError: cannot import name '_default_ds_client_factory'.
  • Fix: SyncService now builds its DS client factory default through the same make_session_aware_client_factory helper DataAppService already uses, so a browser-login session project's Storage/DS calls during sync pull/push work the same way CLI-13 intended everywhere else. The helper is imported locally inside __init__ (not hoisted into the top-level .base import) specifically to keep services/sync_service.py within its grandfathered file-size ceiling — scripts/file_size_baseline.json caps it at 1655 code lines, main was already at 1654, and a straightforward top-level-import fix would have pushed it to 1661 and failed the file's own tests/test_check_file_size.py gate. This version lands at 1653.
  • This is what made PR fix(release): re-enable the winget release job #763 (an unrelated winget release-job fix) show red CI after rebasing onto main — that PR's diff only touches a GitHub Actions workflow file and was never the cause.

Test plan

  • uv run ruff check src/ tests/ scripts/, uv run ruff format . --check, uv run ty check — all clean.
  • uv run python scripts/check_file_size.py — OK: 240 modules within budget, services/sync_service.py at 1653/1655.
  • uv run python scripts/sync_version.py, scripts/check_command_sync.py, scripts/check_version_gates.py, scripts/gen_endpoint_reference.py — no drift.
  • uv run pytest tests/ -q — full local suite: 6787 passed, 184 skipped, 0 failed (previously 62 failed + 124-127 collection errors on main).

Related

PR #759 (session-token support) replaced data_app_service.py's module-level
_default_ds_client_factory with make_session_aware_client_factory(config_store,
DataScienceClient), but left sync_service.py importing the removed name.

Every command reachable through SyncService (pull/push/diff/status, and any
command that imports keboola_agent_cli.cli or the server app at all) failed
at import time with ImportError: cannot import name '_default_ds_client_factory'
-- this broke CI on main across all three jobs (check, test, Windows wheel
build) with 124-127 collection errors plus several failed tests wherever the
import succeeded via a different path.

Wire SyncService's DS client factory default through the same session-aware
factory DataAppService already uses, so a browser-login session project's
Storage/DS calls during pull/push work the same way CLI-13 intended everywhere
else. The factory import is local to __init__ (not hoisted to the module-level
.base import) to keep the file within its grandfathered file-size ceiling.
@Matovidlo
Matovidlo requested a lite review from Copilot September 16, 2026 05:50
@linear-code

linear-code Bot commented Sep 16, 2026

Copy link
Copy Markdown

CLI-13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

A moderate unresolved issue remains: the default session-aware factory lacks a SyncService-level regression test.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Restores SyncService’s session-aware Data Science client factory after CLI-13, fixing import-time failures.

Changes:

  • Replaces the removed factory dependency.
  • Uses the shared session-aware helper via a local import.
File summaries
File Summary
src/keboola_agent_cli/services/sync_service.py Restores DS factory wiring with browser-session support; add a SyncService-level regression test for the default factory.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +269 to +271
self._ds_client_factory = ds_client_factory or make_session_aware_client_factory(
config_store, DataScienceClient
)
@Matovidlo

Copy link
Copy Markdown
Contributor Author

Superseded by #764, which fixed this exact same bug (same root cause: sync_service.py importing the removed _default_ds_client_factory after #759) and already merged to main. Closing this in favor of that fix.

@Matovidlo Matovidlo closed this Sep 16, 2026
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.

2 participants