Skip to content

chore: pass session explicitly in ApiModeration - #39885

Open
HandSonic wants to merge 1 commit into
langgenius:mainfrom
HandSonic:chore/moderation-explicit-session
Open

chore: pass session explicitly in ApiModeration#39885
HandSonic wants to merge 1 commit into
langgenius:mainfrom
HandSonic:chore/moderation-explicit-session

Conversation

@HandSonic

Copy link
Copy Markdown

Summary

For #37403 — make the DB session an explicit parameter in the moderation module, following the pattern from #37402.

  • ApiModeration._get_api_based_extension now takes session: scoped_session and uses it for the query, instead of relying on the implicit global db.session inside the leaf function.
  • Callers (validate_config and _get_config_by_requestor) pass db.session at the call site, so the session dependency of the leaf query is visible in the signature.
  • The other moderation providers (keywords, openai_moderation) do not query the database, so the factory boundary and their signatures stay unchanged.
  • No behavior change.

Testing

  • uv run --project api pytest api/tests/unit_tests/core/moderation -q → 208 passed
  • ruff check / ruff format --check on touched files → pass
  • pyrefly check on touched files → 0 errors

From CodeBuddy Code

Make the DB session an explicit parameter of
ApiModeration._get_api_based_extension instead of relying on the
implicit global db.session inside the query function, following the
pattern from langgenius#37402. Callers (validate_config and
_get_config_by_requestor) now pass db.session at the call site, so the
session dependency of the leaf query is visible in the signature.

The other moderation providers (keywords, openai_moderation) do not
query the database, so the factory boundary and their signatures stay
unchanged.

langgenius#37403
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant