You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps WIQL REST API返回不符合WHERE子句的条目原因排查

Azure DevOps WIQL查询返回异常条目原因及处理方案

原因说明

这个看似不符合条件的条目是Azure DevOps REST API的默认行为:当使用WorkItemLinks查询并指定MODE (MustContain)时,API会自动将查询中作为源节点的工作项(即你指定的[Source].[System.Id] = 1的Epic)以无关联关系的形式返回,作为查询的锚点标识,即便它完全不满足Target的筛选条件。

这个设计是为了让使用者明确当前查询的起始节点,在层级查询场景中辅助关联后续返回的子节点关系。

处理方法

你可以在获取返回结果后,直接过滤掉rel为null且source为null的条目,只保留符合以下条件的有效结果:

  • rel等于System.LinkTypes.Hierarchy-Forward
  • source的id为1
  • target的工作项类型为Issue

示例过滤逻辑(伪代码)

# 假设response是API返回的JSON数据
valid_work_item_relations = []
for relation in response.get("workItemRelations", []):
    if (relation.get("rel") is not None 
        and relation.get("source") is not None 
        and relation["source"]["id"] == 1):
        valid_work_item_relations.append(relation)

内容的提问来源于stack exchange,提问作者TrayMan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 20:42:09