Skip to content

Fix 500 when filtering the dataset list by data_id - #382

Open
Akshats-git wants to merge 1 commit into
openml:mainfrom
Akshats-git:fix/datasets-list-data-id
Open

Akshats-git wants to merge 1 commit into
openml:mainfrom
Akshats-git:fix/datasets-list-data-id

Conversation

@Akshats-git

Copy link
Copy Markdown

Description

list_datasets discarded the result of bindparams(), so the data_id list went to the driver as a plain parameter. With PyMySQL 1.2.4 that's a TypeError and a 500. Assigning the result fixes it, the same way tasks.py does it.

Fixes: #381

Tested against the test database with PyMySQL 1.2.4 and SQLAlchemy 2.1.9, running all four CI marker groups on main and on this branch:

  • test_list_data_id: 4 failed on main, 4 pass here
  • No other changes in results
  • For data_id filters, the Python response matches PHP for [61], [61, 130], [1, 2, 3] and [1, 2, 3, 130], with no key, normaluser and normaluser2

One unrelated thing: test_list_data_identical fails on main too. It sends "status": null, and current FastAPI rejects that with a 422. I left it out of this PR.

Checklist

Always:

  • I have performed a self-review of my own pull request to ensure it contains all relevant information, and the proposed changes are minimal but sufficient to accomplish their task.

Required for code changes:

  • Tests pass locally
  • I have commented my code in hard-to-understand areas, and provided or updated docstrings as needed (N/A)
  • Changes are already covered under existing tests
  • I have added tests that cover the changes (only required if not already under coverage) (N/A)

If applicable:

  • I have made corresponding changes to the documentation pages (/docs) (N/A)

Extra context:

  • This PR and the commits have been created autonomously by a bot/agent.

bindparams() returns a new clause, but the result was discarded, so the
id list was passed to the driver as a plain parameter. PyMySQL 1.2.4 no
longer escapes lists, which turns this into a TypeError.

Fixes openml#381
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When data_id is supplied to list_datasets, the route now assigns the statement returned by bindparams(...) to matching_filter. The linked issue reports that the endpoint returned a 500 because the bound parameter was not applied.

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 0a629

This fixes the 500 error when filtering the dataset list by data_id. The change is small and easy to revert, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: fixing a 500 error when filtering the dataset list by data_id. The raw summary confirms that list_datasets now assigns the bindparams(...) result to matching_filter, …
Description check Passed The description explains the cause (the bindparams() result was discarded, so the data_id list reached the driver as a plain parameter), the fix (assigning the result, as tasks.py does), the linked is…
Linked Issues check Passed [#381] requires that list_datasets assign the result of bindparams() so the data_id list reaches SQLAlchemy as an expanding bind parameter. At the reviewed head, src/routers/datasets.py contai…
Out of Scope Changes check Passed The whole-PR summary reports one changed file, src/routers/datasets.py, with +1/-1 lines. The change assigns the bindparams() result to matching_filter. This directly implements the #381 objecti…
Full details: Title check

Explanation

The title states the main change: fixing a 500 error when filtering the dataset list by data_id. The raw summary confirms that list_datasets now assigns the bindparams(...) result to matching_filter, which addresses this bug. The title is specific and concise.

Full details: Description check

Explanation

The description explains the cause (the bindparams() result was discarded, so the data_id list reached the driver as a plain parameter), the fix (assigning the result, as tasks.py does), the linked issue #381, and the test results. It relates directly to the changeset.

Full details: Linked Issues check

Explanation

[#381] requires that list_datasets assign the result of bindparams() so the data_id list reaches SQLAlchemy as an expanding bind parameter. At the reviewed head, src/routers/datasets.py contains matching_filter = matching_filter.bindparams(bindparam("data_ids", expanding=True)) inside if data_id:, and the clause AND d.did IN :data_ids uses that parameter. This matches the fix requested in #381 and the pattern the issue cites from tasks.py. The PR summary and description state that the base discarded this return value. I did not read the base blob because the diff tool was unavailable, so the base state rests on the supplied PR evidence. The author reports that test_list_data_id moves from 4 failed on main to 4 passed on this branch. I did not run the tests. The remaining item, test_list_data_identical and its "status": null 422, is not part of #381 and is correctly excluded.

Full details: Out of Scope Changes check

Explanation

The whole-PR summary reports one changed file, src/routers/datasets.py, with +1/-1 lines. The change assigns the bindparams() result to matching_filter. This directly implements the #381 objective and introduces no unrelated behavior. The PR description states that the status: null 422 issue in test_list_data_identical is deliberately left out. No other changes are listed in the summary. The diff tool was unavailable, so I could not independently confirm the absence of other hunks. This limit does not change the verdict because the supplied summary covers the whole PR.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74f693b9-5792-4473-8d2a-8c4bb5d469a2
Commits

Reviewing files that changed from the base of the PR and between 621da17 and 0a62968.

Files selected for processing: 1

  • src/routers/datasets.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@sourcery-ai

sourcery-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit 0a62968

#381 `POST /datasets/list` with `data_id` returns 500 · 1 of 1 met

# Requirement Status Notes
1 Fix data_id filtering so it no longer returns a 500. ✅ Met The expanding bind parameter is now assigned back to matching_filter before execution.

@sourcery-ai sourcery-ai 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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

This branch has not been deployed

No deployments
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.

POST /datasets/list with data_id returns 500

1 participant