Skip to content

fix: report actual synced connection count in connector_sync (#1547)#1815

Open
hunterxtang wants to merge 6 commits into
langflow-ai:mainfrom
hunterxtang:fix/1547-connections-synced-count
Open

fix: report actual synced connection count in connector_sync (#1547)#1815
hunterxtang wants to merge 6 commits into
langflow-ai:mainfrom
hunterxtang:fix/1547-connections-synced-count

Conversation

@hunterxtang

@hunterxtang hunterxtang commented Jun 9, 2026

Copy link
Copy Markdown

Fixes #1547
connector_sync reported connections_synced: len(active_connections), but it selects only the first working connection and dispatches a single task, so the count (and the message) were inflated whenever multiple connections were active. Changed to len(task_ids) and fixed the matching message to singular.
Added test_connector_sync_reports_one_connection_with_multiple_active: with 3 active connections it asserts connections_synced == 1. Verified it fails on main (reports 3) and passes with the fix.

Summary by CodeRabbit

  • Bug Fixes

    • Connector sync responses now correctly report the number of connections started based on returned task IDs.
    • Response messaging uses singular wording when a single connection is started for clearer, grammatically correct feedback.
  • Tests

    • Added unit tests validating HTTP status, task ID reporting, and correct singular/plural messaging in connector sync responses.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bd09f3c9-f1f8-4d1b-b46d-5c6ad840f278

📥 Commits

Reviewing files that changed from the base of the PR and between baaad33 and f49fd12.

📒 Files selected for processing (1)
  • tests/unit/api/test_connector_sync_response.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unit/api/test_connector_sync_response.py

Walkthrough

connector_sync now sets connections_synced from the number of dispatched tasks (len(task_ids)) and uses a singular message when appropriate. A new async unit test verifies the HTTP 201 response, message wording, connections_synced value, returned task_ids, and that only one sync task was dispatched and awaited.

Changes

Connector sync response count

Layer / File(s) Summary
Connector sync response count fix
src/api/connectors.py, tests/unit/api/test_connector_sync_response.py
Updates connector_sync to compute connections_synced from len(task_ids) instead of len(active_connections), adjusts the success message to report a single {connector_type} connection when applicable, and adds a unit test validating the status code, JSON fields (connections_synced, message, task_ids), and that sync_specific_files is awaited exactly once.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

bug

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing the inaccurate reporting of connections_synced count in connector_sync.
Linked Issues check ✅ Passed The PR addresses all coding requirements from issue #1547: reporting connections_synced as len(task_ids) instead of len(active_connections), updating message wording to singular, and adding comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the connections_synced count issue; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) tests bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Jun 9, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unit/api/test_connector_sync_response.py`:
- Line 109: Remove the stray signature comment "# Made with Bob" from the test
file; locate the comment in tests/unit/api/test_connector_sync_response.py
(search for the exact string "# Made with Bob") and delete that line so the file
contains only test code and no personal/signature comments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4f582f41-8469-44a9-9926-c634d14a82f2

📥 Commits

Reviewing files that changed from the base of the PR and between 03f1c91 and 5eae082.

📒 Files selected for processing (2)
  • src/api/connectors.py
  • tests/unit/api/test_connector_sync_response.py

Comment thread tests/unit/api/test_connector_sync_response.py Outdated
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Jun 9, 2026
@hunterxtang hunterxtang force-pushed the fix/1547-connections-synced-count branch from 8512d02 to baaad33 Compare June 10, 2026 21:02
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Jun 10, 2026
@Wallgau Wallgau requested a review from ricofurtado June 11, 2026 17:48
The connector_sync function signature was updated in langflow-ai#1782 to include
request and session parameters. This test was written against the old
signature and failed with TypeError before reaching any assertions.

Fixes the test to pass both required parameters as MagicMock instances.
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Jun 11, 2026

@richardz403 richardz403 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.

Ran the unit test test_connector_sync_response and the changes seem to be in order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working. community tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: sync_all_connectors reports inflated connections_synced count

2 participants