Skip to content

feat: import dsl add integration test#34498

Open
fatelei wants to merge 2 commits intolanggenius:mainfrom
fatelei:issue-34497
Open

feat: import dsl add integration test#34498
fatelei wants to merge 2 commits intolanggenius:mainfrom
fatelei:issue-34497

Conversation

@fatelei
Copy link
Copy Markdown
Contributor

@fatelei fatelei commented Apr 3, 2026

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

fix #34497

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 and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

Pyrefly Diff

No changes detected.

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

Pyrefly Diff

No changes detected.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

Pyrefly Diff

No changes detected.

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

Pyrefly Diff

No changes detected.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

Pyrefly Diff

No changes detected.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

Pyrefly Diff

No changes detected.

@asukaminato0721 asukaminato0721 requested a review from Copilot April 3, 2026 11:51
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds/updates integration coverage around App DSL import in the testcontainers suite, aiming to prevent regressions related to the session type used during imports.

Changes:

  • Use CURRENT_DSL_VERSION in test YAML generation to avoid hardcoding the DSL version.
  • Add a new integration test intended to validate chat-app import behavior when using an engine-bound SQLAlchemy Session.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +415 to +418
with ``Session(db.engine)`` in AppImportApi.post(). The previous
approach returned a ``SessionTransaction`` instead of a ``Session``,
which broke AppDslService operations such as ``session.scalar()`` and
``session.add()``.
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring claims sessionmaker(db.engine).begin() returns a SessionTransaction (and not a Session). That’s only true when calling .begin() directly; when used as with sessionmaker(...).begin() as session, the as binding is a Session. Please reword this explanation to accurately describe the failure mode being guarded against (e.g., passing a SessionTransaction into AppDslService).

Suggested change
with ``Session(db.engine)`` in AppImportApi.post(). The previous
approach returned a ``SessionTransaction`` instead of a ``Session``,
which broke AppDslService operations such as ``session.scalar()`` and
``session.add()``.
with ``Session(db.engine)`` in AppImportApi.post(). The important
behavior is that AppDslService must receive a real ``Session``.
The previous pattern was problematic because it could result in
passing a transaction-oriented object into AppDslService instead of
a ``Session``, which broke operations such as ``session.scalar()``
and ``session.add()``.

Copilot uses AI. Check for mistakes.
yaml_content=yaml_content,
name="Engine-session import",
)
session.commit()
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test manually calls session.commit() after import_app(), but AppImportApi.post() (which this test references) does not commit the Session(db.engine) before closing it. As written, the test can pass even if the real endpoint still drops uncommitted changes (e.g., the newly-added AppModelConfig). Consider either (1) exercising the actual import API route via the test client, or (2) removing the explicit commit here so the test matches production behavior and forces the service/controller to commit as needed.

Suggested change
session.commit()

Copilot uses AI. Check for mistakes.
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 size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] import dsl add integration test

3 participants