Skip to content

[backplane][foundation] 抽取 _non_empty_str 非空字符串校验为共享 helper #8

Description

@beachspainc

现状与证据

_non_empty_strappssrc/cobnet 出现重复定义,且在当前文件中行为完全一致(空字符串/非字符串直接报错并返回字段化错误):

  • apps/server/usecase/workspace/tools.py:29
  • src/cobnet/driver/agent/workflow.py:49

重复函数签名与异常行为一致,当前会造成字段校验逻辑重复维护。

建议

优先在 src/cobnet/backplane(或 src/cobnet/runtime 的通用验证工具层)提取统一实现,例如:

  • ensure_non_empty_str(value: object, *, field: str) -> str

并替换两处调用。

验收

  • 删除上述两处重复实现。
  • 保持报错文案与现有行为一致。
  • 增加回归:空值/非字符串/空白字符串。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions