Skip to content

fix(api): use SPARQLWrapper.setMethod() for POST requests - #82

Open
prathamesh04 wants to merge 2 commits into
dbpedia:mainfrom
prathamesh04:fix/sparql-post-method-v2
Open

fix(api): use SPARQLWrapper.setMethod() for POST requests#82
prathamesh04 wants to merge 2 commits into
dbpedia:mainfrom
prathamesh04:fix/sparql-post-method-v2

Conversation

@prathamesh04

@prathamesh04 prathamesh04 commented Jul 28, 2026

Copy link
Copy Markdown

Description

The SPARQLWrapper library does not expose as a settable public attribute. Direct assignment () is silently ignored, causing all SPARQL queries to use GET instead of POST.

This fix uses the correct API: .

Changes

  • Changed to in

Testing

  • Verified that SPARQLWrapper documentation recommends using API
  • The fix ensures large SPARQL queries (e.g., from collection endpoints) are sent via POST, avoiding URL length limits

Fixes #69

Summary by CodeRabbit

  • Bug Fixes
    • Improved SPARQL endpoint requests by correctly applying the POST method, ensuring queries execute reliably.
  • Tests
    • Updated the lightweight SPARQL wrapper test double to support setting the request method, improving compatibility with the updated request behavior.

The SPARQLWrapper library does not expose .method as a settable public
attribute. Direct assignment (sparql.method = 'POST') is silently
ignored, causing all SPARQL queries to use GET instead of POST.

This fix uses the correct API: sparql.setMethod('POST').

Fixes dbpedia#69
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5e99b560-44e6-4ae9-b886-9480c08b2ac2

📥 Commits

Reviewing files that changed from the base of the PR and between 5b30f7f and 0542f4b.

📒 Files selected for processing (1)
  • tests/conftest.py

📝 Walkthrough

Walkthrough

The SPARQL endpoint query now calls setMethod("POST") instead of assigning the method attribute directly. The test fake supports and records this setter call.

Changes

SPARQL POST method fix

Layer / File(s) Summary
Configure SPARQL POST requests
databusclient/api/download.py, tests/conftest.py
_query_sparql_endpoint uses SPARQLWrapper’s setMethod("POST") API, while DummySPARQL records the configured method.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the fix and testing, but omits required template sections like Related Issues, Type of change, and Checklist. Add the missing template sections, including Related Issues, Type of change, and the checklist items, or note why any are not applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the core fix: switching SPARQL POST requests to SPARQLWrapper.setMethod().
Linked Issues check ✅ Passed [#69] The code change matches the issue by replacing direct method assignment with setMethod("POST") and updating the test double.
Out of Scope Changes check ✅ Passed The only code changes are the intended API call fix and matching test mock update, with no unrelated edits.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@coderabbitai coderabbitai Bot 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.

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 `@databusclient/api/download.py`:
- Line 598: Update the fallback DummySPARQL in tests/conftest.py to implement
setMethod and store the supplied HTTP method, matching the production call used
by _query_sparql_endpoint. Preserve the existing test-double behavior while
preventing AttributeError when the real SPARQL dependency is unavailable.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c84435f2-faf0-459e-8e54-919160f83453

📥 Commits

Reviewing files that changed from the base of the PR and between ce39277 and 5b30f7f.

📒 Files selected for processing (1)
  • databusclient/api/download.py

Comment thread databusclient/api/download.py
@prathamesh04

Copy link
Copy Markdown
Author

cc @Integer-Ctrl @DhanashreePetare @JJ-Author

This PR fixes the SPARQL POST method bug (Issue #69). The current code uses which is silently ignored by SPARQLWrapper. This fix uses the correct API: .

@prathamesh04

prathamesh04 commented Jul 29, 2026

Copy link
Copy Markdown
Author

Hey @Integer-Ctrl @DhanashreePetare @JJ-Author — I've added a testing video demonstrating the fix working against a local SPARQL endpoint (Apache Jena Fuseki). The fix replaces the silently-ignored sparql.method = "POST" with sparql.setMethod("POST"), and all 18 unit tests pass. Could you review when you get a chance? Thanks!
video:
Screencast from 2026-07-29 17-42-40.webm

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.

bug:sparql.method = "POST" silently ignored — SPARQL queries always use GET

1 participant