Skip to content

chore: example to color the session - #37402

Merged
asukaminato0721 merged 3 commits into
langgenius:mainfrom
asukaminato0721:make-db.session-obvious
Jun 15, 2026
Merged

asukaminato0721 merged 3 commits into
langgenius:mainfrom
asukaminato0721:make-db.session-obvious

Conversation

@asukaminato0721

@asukaminato0721 asukaminato0721 commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

make session dep explicitly.

#37403

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • 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 && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 13, 2026
@dosubot dosubot Bot added the refactor label Jun 13, 2026
@github-actions

github-actions Bot commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-06-13 02:26:43.933478735 +0000
+++ /tmp/pyrefly_pr.txt	2026-06-13 02:26:29.331410513 +0000
@@ -4411,6 +4411,16 @@
   --> tests/unit_tests/core/rag/extractor/test_markdown_extractor.py:30:16
 ERROR Argument `SimpleNamespace` is not assignable to parameter `document_model` with type `Document | None` in function `core.rag.extractor.notion_extractor.NotionExtractor.update_last_edited_time` [bad-argument-type]
    --> tests/unit_tests/core/rag/extractor/test_notion_extractor.py:435:43
+ERROR Missing argument `session` in function `core.rag.index_processor.processor.paragraph_index_processor.ParagraphIndexProcessor._extract_images_from_text` [missing-argument]
+   --> tests/unit_tests/core/rag/indexing/processor/test_paragraph_index_processor.py:538:70
+ERROR Missing argument `session` in function `core.rag.index_processor.processor.paragraph_index_processor.ParagraphIndexProcessor._extract_images_from_text` [missing-argument]
+   --> tests/unit_tests/core/rag/indexing/processor/test_paragraph_index_processor.py:545:65
+ERROR Missing argument `session` in function `core.rag.index_processor.processor.paragraph_index_processor.ParagraphIndexProcessor._extract_images_from_text` [missing-argument]
+   --> tests/unit_tests/core/rag/indexing/processor/test_paragraph_index_processor.py:572:70
+ERROR Missing argument `session` in function `core.rag.index_processor.processor.paragraph_index_processor.ParagraphIndexProcessor._extract_images_from_segment_attachments` [missing-argument]
+   --> tests/unit_tests/core/rag/indexing/processor/test_paragraph_index_processor.py:614:85
+ERROR Missing argument `session` in function `core.rag.index_processor.processor.paragraph_index_processor.ParagraphIndexProcessor._extract_images_from_segment_attachments` [missing-argument]
+   --> tests/unit_tests/core/rag/indexing/processor/test_paragraph_index_processor.py:626:91
 ERROR Argument `None` is not assignable to parameter `state` with type `InstanceState[Any]` in function `sqlalchemy.orm.exc.ObjectDeletedError.__init__` [bad-argument-type]
    --> tests/unit_tests/core/rag/indexing/test_indexing_runner.py:926:84
 ERROR Argument `Literal['completed']` is not assignable to parameter `after_indexing_status` with type `IndexingStatus` in function `core.indexing_runner.IndexingRunner._update_document_index_status` [bad-argument-type]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 48.40% 48.40% 0.00%
Strict coverage 47.90% 47.90% 0.00%
Typed symbols 27,588 27,588 0
Untyped symbols 29,722 29,722 0
Modules 2877 2877 0

@asukaminato0721
asukaminato0721 added this pull request to the merge queue Jun 15, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 15, 2026
Merged via the queue into langgenius:main with commit de2ec99 Jun 15, 2026
32 checks passed
@asukaminato0721
asukaminato0721 deleted the make-db.session-obvious branch June 15, 2026 18:21
jashwanth-reddy-g pushed a commit to jashwanth-reddy-g/dify that referenced this pull request Jun 24, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
jashwanth-reddy-g pushed a commit to jashwanth-reddy-g/dify that referenced this pull request Jun 24, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Ssazurov pushed a commit to Ssazurov/dify that referenced this pull request Aug 8, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
yuee3 added a commit to yuee3/dify that referenced this pull request Oct 10, 2026
… a local

`ApiExternalDataTool.validate_config` and `query` reached for `db.session`
inside the method body. The previous revision aliased that to a local
variable, which documents the dependency no better: the signature still does
not say the method reads the database, and neither does any call site.

Both methods now take `session: Session | scoped_session` and query through
it. `ExternalDataTool`'s two abstract methods declare the same parameter, and
`ExternalDataToolFactory` — their only caller — passes `db.session`, so the
dependency is visible at the call site. Same shape as the example in langgenius#37402
and as `get_message_data(message_id, session)` merged in langgenius#42753.

`api.py` no longer imports `db`; `factory.py` imports it instead.

Tests follow the signature: `test_api.py` drops the `_DatabaseBinding`
monkeypatch that stood in for the module-level `db` and passes the real SQLite
session, `test_factory.py` asserts `db.session` reaches the extension, and
`test_base.py`'s concrete subclasses take the new parameter.

Refs langgenius#37403
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer 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.

2 participants