Skip to content

fix: type object 'str' has no attribute 'LLM'#33899

Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom
fatelei:issue-33891
Mar 23, 2026
Merged

fix: type object 'str' has no attribute 'LLM'#33899
asukaminato0721 merged 1 commit intolanggenius:mainfrom
fatelei:issue-33891

Conversation

@fatelei
Copy link
Copy Markdown
Contributor

@fatelei fatelei commented Mar 23, 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 #33891

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

Copilot AI review requested due to automatic review settings March 23, 2026 05:38
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Mar 23, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a type error where str objects were incorrectly expected to have an LLM attribute, likely stemming from an incorrect usage of node types. The fix involves refactoring the usage of NodeType.LLM to BuiltinNodeTypes.LLM in relevant test files, ensuring proper type handling for workflow node executions. Additionally, the pypandoc library has been introduced as a new project dependency.

Highlights

  • Type Refactoring: References to NodeType.LLM in test files were updated to BuiltinNodeTypes.LLM, and the corresponding import was changed from NodeType to BuiltinNodeTypes. This addresses a potential type mismatch or incorrect enum usage related to workflow node executions.
  • Dependency Addition: The pypandoc library was added as a new dependency in pyproject.toml and subsequently locked in uv.lock.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a TypeError by replacing the incorrect NodeType with BuiltinNodeTypes in the test files. However, it also introduces a new dependency, pypandoc, which appears to be unrelated to the primary fix. To adhere to the principle of atomic changes, it would be best to move the dependency addition to a separate pull request unless it is a prerequisite for this fix.

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-03-23 05:39:38.930033499 +0000
+++ /tmp/pyrefly_pr.txt	2026-03-23 05:39:29.554041321 +0000
@@ -4388,8 +4388,6 @@
    --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_execution_repository.py:214:33
 ERROR `None` is not assignable to attribute `_creator_user_role` with type `CreatorUserRole` [bad-assignment]
    --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_execution_repository.py:219:35
-ERROR Class `str` has no class attribute `LLM` [missing-attribute]
-  --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_node_execution_repository.py:70:19
 ERROR Argument `object` is not assignable to parameter `session_factory` with type `Engine | sessionmaker[Unknown]` in function `core.repositories.sqlalchemy_workflow_node_execution_repository.SQLAlchemyWorkflowNodeExecutionRepository.__init__` [bad-argument-type]
    --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_node_execution_repository.py:133:29
 ERROR Attribute `current_tenant_id` of class `Account` is a read-only property and cannot be set [read-only]
@@ -4400,16 +4398,12 @@
    --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_node_execution_repository.py:245:31
 ERROR Argument `None` is not assignable to parameter `orig` with type `BaseException` in function `sqlalchemy.exc.DBAPIError.__init__` [bad-argument-type]
    --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_node_execution_repository.py:267:83
-ERROR Class `str` has no class attribute `LLM` [missing-attribute]
-   --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_node_execution_repository.py:390:26
 ERROR Argument `SimpleNamespace` is not assignable to parameter `value` with type `SQLCoreOperations[UploadFile | None] | UploadFile | None` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_node_execution_repository.py:405:19
 ERROR Argument `SimpleNamespace` is not assignable to parameter `value` with type `SQLCoreOperations[UploadFile | None] | UploadFile | None` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_node_execution_repository.py:406:20
 ERROR Argument `SimpleNamespace` is not assignable to parameter `value` with type `SQLCoreOperations[UploadFile | None] | UploadFile | None` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_node_execution_repository.py:407:21
-ERROR Class `str` has no class attribute `LLM` [missing-attribute]
-   --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_node_execution_repository.py:444:26
 ERROR Argument `None` is not assignable to parameter `orig` with type `BaseException` in function `sqlalchemy.exc.DBAPIError.__init__` [bad-argument-type]
    --> tests/unit_tests/core/repositories/test_sqlalchemy_workflow_node_execution_repository.py:619:61
 ERROR Cannot index into `dict[str, WorkflowNodeExecutionModel]` [bad-index]

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

Fixes a unit-test failure caused by treating NodeType (a str type alias) as an enum with members like .LLM, and adds an explicit runtime dependency for pypandoc which is imported by extractors/nodes.

Changes:

  • Update workflow node execution repository unit tests to use BuiltinNodeTypes.LLM instead of NodeType.LLM.
  • Add pypandoc to the API Python dependencies and lockfile.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
api/tests/unit_tests/core/repositories/test_sqlalchemy_workflow_node_execution_repository.py Switches test node type constants from NodeType.LLM to BuiltinNodeTypes.LLM to avoid AttributeError.
api/pyproject.toml Adds pypandoc as an explicit dependency.
api/uv.lock Locks pypandoc and wires it into the resolved dependency set.

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

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 23, 2026
@asukaminato0721 asukaminato0721 merged commit 01d97fa into langgenius:main Mar 23, 2026
17 of 19 checks passed
@bowenliang123
Copy link
Copy Markdown
Contributor

Why the pandoc is added as dependency? It's unrelated to the problem or the title.

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:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'Flask' object has no attribute 'login_manager' FAILED

4 participants