Skip to content

refactor(models): pass session into WorkflowAppLog accessors - #41440

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
keith991001:refactor/workflow-app-log-session-param
Aug 28, 2026
Merged

asukaminato0721 merged 1 commit into
langgenius:mainfrom
keith991001:refactor/workflow-app-log-session-param

Conversation

@keith991001

Copy link
Copy Markdown
Contributor

Important

  1. Read CONTRIBUTING.md.
  2. Associated issue: rewrite property to accept session: Session as parameter #40372 (claimed the WorkflowAppLog slice in this comment).

Summary

Part of #40372, follow-up to #41370.

Converts the two WorkflowAppLog @property accessors in api/models/workflow.py that reach for the global db.session internally into plain methods taking session: Session explicitly, per the pattern established in #40370 / #40797:

  • WorkflowAppLog.created_by_account — now def created_by_account(self, session) -> Account | None.
  • WorkflowAppLog.created_by_end_user — now def created_by_end_user(self, session).

Unlike the zero-call-site slices, these two accessors are read implicitly (from_attributes=True) by WorkflowAppLogPartialResponse in both the console and service_api workflow-app-log endpoints. Both endpoints already serialize inside an explicit sessionmaker(...).begin() block and already wrap each row in the LogView view object, so the session is threaded through LogView (following the session-carrying wrapper pattern of SegmentWithSummary from #36522):

  • LogView now takes the query session and exposes created_by_account / created_by_end_user as properties that resolve through it; all other attributes keep proxying to the underlying WorkflowAppLog.
  • No controller changes are needed — both endpoints keep validating the same pagination payload.

Not touching Workflow.* (claimed by another contributor on the issue), WorkflowRun.*, or WorkflowNodeExecutionModel.*.

Tests

  • New api/tests/unit_tests/models/test_workflow_app_log_models.py: exercises both accessors against the real sqlite_session fixture, covering the role-based dispatch (ACCOUNT vs END_USER) and the None paths, mirroring test_trigger_models.py from refactor(models): dep-inject Session on remaining @property accessors #40797.
  • test_workflow_app_service_metadata.py: adapted to the new LogView signature and extended with a test asserting the accessors resolve through the session the view was built with.

Screenshots

N/A (backend-only refactor).

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 vp staged (frontend) to appease the lint gods

From Claude Code

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels Aug 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 61.39% 61.39% +0.01%
Strict coverage 60.98% 60.99% +0.01%
Typed symbols 42,391 42,406 +15
Untyped symbols 26,841 26,841 0
Modules 3276 3277 +1

@asukaminato0721 asukaminato0721 self-assigned this Aug 28, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 28, 2026
@asukaminato0721
asukaminato0721 added this pull request to the merge queue Aug 28, 2026
Merged via the queue into langgenius:main with commit e6fc0a8 Aug 28, 2026
37 checks passed
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