Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/dbgpt-core/src/dbgpt/util/cli/_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@


def _is_flow_operator(cls):
return (
issubclass(cls, BaseOperator)
and hasattr(cls, "metadata")
and isinstance(cls.metadata, ViewMetadata)
)
try:
metadata = getattr(cls, "metadata", None)
if metadata is None:
return False
# For class-level properties or descriptors, get the actual metadata object
if callable(metadata):
metadata = metadata()
Comment on lines +16 to +21

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Check BaseOperator before invoking metadata.

_scan_awel_flow uses base_class=object, so this predicate runs for every discovered class. Lines [20]-[21] invoke any callable metadata before confirming that cls is a BaseOperator; an unrelated class with a no-argument metadata method can therefore execute during startup. Move the subclass check ahead of metadata resolution.

return issubclass(cls, BaseOperator) and isinstance(metadata, ViewMetadata)
Comment on lines +20 to +22

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reuse the resolved metadata downstream.

For callable cls.metadata, this helper returns True after resolving a ViewMetadata, but _scan_awel_flow later reads cls.metadata directly at Line [50], so it receives the callable and .parameters raises. It also re-evaluates the provider at Line [70]. Return or cache the resolved metadata and reuse the same object for extraction and classification.

except Exception:
return False
Comment on lines +15 to +24

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add regression tests for metadata resolution.

Cover normal ViewMetadata, callable providers, missing/invalid metadata, providers that raise, unrelated classes with callable metadata, and the full _scan_awel_flow path.

As per path instructions, “公共行为变更必须提供邻近的回归测试,并覆盖相关的正常、错误、空输入、并发、取消或流式场景。”

🧰 Tools
🪛 Ruff (0.15.21)

[warning] 23-23: Do not catch blind exception: Exception

(BLE001)

Source: Path instructions



def _is_flow_resource(cls):
Expand Down
Loading