Skip to content

test(knowledge): persist query image fixtures in SQLite - #44980

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
Winoren:test/query-images-sqlite
Oct 28, 2026
Merged

asukaminato0721 merged 1 commit into
langgenius:mainfrom
Winoren:test/query-images-sqlite

Conversation

@Winoren

@Winoren Winoren commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Contributes to #44973: migrate the query-image persistence scenarios in services/knowledge_fs/test_query_images.py.

The previous _Session, _install_files, and file-controller doubles returned supplied objects without exercising database lookups or commit behavior. Use the shared SQLite fixtures to persist real UploadFile and ToolFile rows and execute the actual lookup and authorization paths instead.

  • Read usage markers through a separate session to verify they were committed, and verify oversized requests leave no persisted usage markers.
  • Exercise preview filtering with a persisted foreign-tenant file owned by the same account.
  • Check both upload and tool-file grants after the backing row is deleted or moved to another tenant.
  • Retain storage, clock, and URL-signing substitutions; no live storage service is required.

This is a test-only change and one part of the issue's broader inventory. Production behavior is unchanged.

Validation

  • Original query-image module: 14 passed. Migrated module: 18 passed.
  • Query-image, service query-image upload, and file-service modules together: 88 passed (one existing optional-libmagic warning).
  • make lint: passed, including all 75 import contracts.
  • Strict unit-test Pyrefly for the changed file: 0 diagnostics.
  • make type-check: fails on two Tencent tracing imports (entities.semconv and entities.tencent_trace_entity). The identical two errors reproduce with the original test file on the same upstream base, 0bd201254da45ddab1e15950d1f2af277de67240.
  • uv lock --project api --check with CI's uv 0.13.6: passed.
  • Negative controls: removing the upload lookup's tenant filter leaves the original tests green but fails the migrated tests; replacing the usage commit with a flush also fails the migrated tests. All deliberate production mutations were restored before submission.

Screenshots

Not applicable (backend tests only).

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 verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

No documentation or frontend changes. Backend check results are recorded above rather than marking the combined checklist item as passed.

AI assistance was used to inspect the existing contracts, migrate the fixtures, and run the validation and negative controls described above.

From Codex

@Winoren
Winoren requested a review from QuantumGhost as a code owner October 28, 2026 12:47
@github-actions github-actions Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 79.89% 79.90% +0.00%
Strict coverage 79.58% 79.59% +0.00%
Typed symbols 76,613 76,629 +16
Untyped symbols 19,357 19,356 -1
Modules 3979 3979 0

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.53%. Comparing base (0bd2012) to head (b3664cb).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #44980   +/-   ##
=======================================
  Coverage   89.53%   89.53%           
=======================================
  Files        6009     6009           
  Lines      376837   376837           
  Branches    76232    76232           
=======================================
  Hits       337385   337385           
- Misses      33455    33457    +2     
+ Partials     5997     5995    -2     
Flag Coverage Δ
api 89.39% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@asukaminato0721 asukaminato0721 self-assigned this Oct 28, 2026
@asukaminato0721
asukaminato0721 added this pull request to the merge queue Oct 28, 2026
Merged via the queue into langgenius:main with commit d08d4e2 Oct 28, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants