[PR #31104] refactor: replace request.args.get with Pydantic BaseModel validation #33088

Closed
opened 2026-02-21 20:52:38 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/31104

State: closed
Merged: Yes


Summary

Replaced all instances of request.args.get(default=None, type=str) with Pydantic BaseModel validation for better type safety and maintainability.

This PR addresses the issue where Flask's request.args.get with type=str doesn't work well with strict type annotations in Werkzeug/Flask, causing type errors and making code harder to maintain.

Files updated:

  • controllers/console/tag/tags.py (TagListQuery)
  • controllers/console/datasets/data_source.py (DataSourceNotionListQuery, DataSourceNotionPreviewQuery)
  • controllers/console/datasets/datasets.py (ConsoleDatasetListQuery)
  • controllers/console/datasets/external.py (ExternalApiTemplateListQuery)
  • controllers/console/explore/installed_app.py (InstalledAppsListQuery)
  • controllers/service_api/dataset/dataset.py (DatasetListQuery)
  • controllers/service_api/dataset/document.py (DocumentListQuery)

Fixes #31077

Checklist

  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

gittensor:u146701565

**Original Pull Request:** https://github.com/langgenius/dify/pull/31104 **State:** closed **Merged:** Yes --- ## Summary Replaced all instances of `request.args.get(default=None, type=str)` with Pydantic BaseModel validation for better type safety and maintainability. This PR addresses the issue where Flask's `request.args.get` with `type=str` doesn't work well with strict type annotations in Werkzeug/Flask, causing type errors and making code harder to maintain. ### Files updated: - `controllers/console/tag/tags.py` (TagListQuery) - `controllers/console/datasets/data_source.py` (DataSourceNotionListQuery, DataSourceNotionPreviewQuery) - `controllers/console/datasets/datasets.py` (ConsoleDatasetListQuery) - `controllers/console/datasets/external.py` (ExternalApiTemplateListQuery) - `controllers/console/explore/installed_app.py` (InstalledAppsListQuery) - `controllers/service_api/dataset/dataset.py` (DatasetListQuery) - `controllers/service_api/dataset/document.py` (DocumentListQuery) Fixes #31077 ## Checklist - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `make lint` and `make type-check` (backend) and `cd web && npx lint-staged` (frontend) to appease the lint gods --- gittensor:u146701565
yindo added the pull-request label 2026-02-21 20:52:38 -05:00
yindo closed this issue 2026-02-21 20:52:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33088