Skip to content

fix: add timeouts to Wikidata requests#13757

Open
cyphercodes wants to merge 2 commits into
langflow-ai:release-1.11.0from
cyphercodes:fix/wikidata-timeouts
Open

fix: add timeouts to Wikidata requests#13757
cyphercodes wants to merge 2 commits into
langflow-ai:release-1.11.0from
cyphercodes:fix/wikidata-timeouts

Conversation

@cyphercodes

@cyphercodes cyphercodes commented Jun 20, 2026

Copy link
Copy Markdown

Summary

  • Add bounded timeouts to both Wikidata component HTTP requests.
  • Cover the timeout argument for the current component and legacy tool wrapper.

Fixes #13655

Testing

  • uv run --group dev pytest -q src/backend/tests/unit/components/search/test_wikidata_api.py
  • uv run ruff format --check src/lfx/src/lfx/components/tools/wikidata_api.py src/lfx/src/lfx/components/wikipedia/wikidata.py src/backend/tests/unit/components/search/test_wikidata_api.py
  • uv run ruff check src/lfx/src/lfx/components/tools/wikidata_api.py src/lfx/src/lfx/components/wikipedia/wikidata.py src/backend/tests/unit/components/search/test_wikidata_api.py
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of Wikidata data retrieval by adding timeout handling to prevent indefinite waiting on API calls.
  • Tests

    • Updated test coverage for Wikidata API interactions.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fabd10c9-1503-4d7b-a39b-f8cb0d6370ed

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Both Wikidata component modules (lfx.components.tools.wikidata_api and lfx.components.wikipedia.wikidata) gain a WIKIDATA_API_TIMEOUT = 10.0 constant that is passed as timeout= to their httpx.get calls. Tests are updated to alias each module's timeout separately and assert the correct timeout and endpoint parameters per module.

Changes

Wikidata Bounded Timeout

Layer / File(s) Summary
WIKIDATA_API_TIMEOUT constants and httpx.get wiring
src/lfx/src/lfx/components/tools/wikidata_api.py, src/lfx/src/lfx/components/wikipedia/wikidata.py
Both modules define WIKIDATA_API_TIMEOUT = 10.0 and pass it as timeout=WIKIDATA_API_TIMEOUT to their httpx.get calls, replacing the previous default-timeout behavior.
Test assertions for per-module timeouts
src/backend/tests/unit/components/search/test_wikidata_api.py
Imports alias each module's timeout constant separately (WIKIPEDIA_WIKIDATA_API_TIMEOUT for the wikipedia module). Patch targets for httpx.get are corrected to lfx.components.wikipedia.wikidata. Assertions extended to validate wbsearchentities params and the correct timeout constant per path. A new legacy-wrapper test verifies WikidataAPIWrapper().results() uses timeout=WIKIDATA_API_TIMEOUT from the tools module.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 7 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Quality And Coverage ⚠️ Warning Tests validate timeout parameter is passed to httpx.get() but lack critical coverage: no tests for actual timeout exceptions (httpx.ReadTimeout/ConnectTimeout), and empty response test doesn't veri... Add tests for timeout exception scenarios: test what happens when httpx raises ReadTimeout/ConnectTimeout in both WikidataComponent and WikidataAPIWrapper, and verify empty_response test validates timeout parameter.
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: add timeouts to Wikidata requests' accurately summarizes the main change—adding timeout parameters to Wikidata HTTP requests across two components.
Linked Issues check ✅ Passed All coding requirements from issue #13655 are met: both Wikidata components now explicitly pass timeout parameters to httpx.get() calls, with unit tests validating the timeout behavior.
Out of Scope Changes check ✅ Passed All changes are directly related to the issue objective. Modifications are confined to adding WIKIDATA_API_TIMEOUT constants and passing timeout arguments to httpx.get() calls in both Wikidata components and their corresponding tests.
Test Coverage For New Implementations ✅ Passed PR includes comprehensive test coverage for the timeout bug fix: test file has 6 methods covering both WikidataComponent and WikidataAPIWrapper, with explicit assertions validating timeout=10.0 par...
Test File Naming And Structure ✅ Passed Test file follows all correct patterns: test_*.py naming, proper pytest structure with fixtures and decorators, descriptive test function names, organized class-based tests with proper inheritance,...
Excessive Mock Usage Warning ✅ Passed Mock usage is appropriate: only 4 external httpx.get mocks in 6 tests, all internal component logic is real, timeouts properly verified, no excessive or unnecessary mocking.

✏️ 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 bug Something isn't working and removed bug Something isn't working labels Jun 20, 2026
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant