# 查询工作流作业节点

读取指定作业中一个节点的执行细节，包括节点定义和本次运行输入输出。

```text
GET https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/{workflow_id}/executions/{execution_id}/nodes/{node_key}
```

## 调用前准备

先[查询工作流作业结果](get-workflow-job-result.md)确认节点执行情况，再从工作流 DSL 取得节点键。准备有目标工作区访问权限的个人访问令牌和目标工作区 ID。

下方示例使用：

- `$AI_STUDIO_API_KEY`：实际个人访问令牌，通过 `X-API-Key` Header 传递。
- `$WORKSPACE_ID`：目标工作区 ID，通过 `X-Workspace-ID` Header 传递。
- `$WORKFLOW_ID`：作业所属的工作流 ID。
- `$EXECUTION_ID`：作业执行 ID。
- `$NODE_KEY`：工作流 DSL 中的节点键。

## 路径参数

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `workflow_id` | string | 工作流 ID。 |
| `execution_id` | string | 作业 ID。 |
| `node_key` | string | 工作流 DSL 中的节点键。 |

## 请求示例

```bash
curl "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/$WORKFLOW_ID/executions/$EXECUTION_ID/nodes/$NODE_KEY" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## 成功响应

成功时返回 `200`。`data.node` 描述节点定义，`data.run` 描述该节点在本次作业中的运行情况。

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "node": {
      "flow_id": "flow-001",
      "name": "load",
      "node_key": "root.load",
      "node_type": "operator",
      "display_name": "加载数据",
      "workitem_id": "wi-001",
      "node_execution_id": "node-exec-001"
    },
    "run": {
      "status": "COMPLETED",
      "started_at": "2026-08-18T10:00:00Z",
      "ended_at": "2026-08-18T10:00:01Z",
      "duration_ms": 1200,
      "runtime_input": {},
      "runtime_output": {},
      "config": {},
      "metrics": {}
    }
  }
}
```

响应字段如下。

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `code` | string | 成功时为 `OK`。 |
| `msg` | string | 成功时为 `OK`。 |
| `data.node.flow_id` | string | 节点所属流程 ID。 |
| `data.node.name` | string | 节点名称。 |
| `data.node.node_key` | string | DSL 节点键。 |
| `data.node.node_type` | string | 节点类型。 |
| `data.node.display_name` | string | 节点显示名称。 |
| `data.node.workitem_id` | string | 工作项标识；有值时返回。 |
| `data.node.node_execution_id` | string | 节点执行标识；有值时返回。 |
| `data.run.status` | string | 节点当前或最终状态。 |
| `data.run.started_at` | string | 节点运行开始时间；未产生时可能省略。 |
| `data.run.ended_at` | string | 节点运行结束时间；未产生时可能省略。 |
| `data.run.duration_ms` | integer | 节点运行耗时（毫秒）；未产生时可能省略。 |
| `data.run.error` | string | 节点执行错误；有错误时返回。 |
| `data.run.runtime_input` | 任意 JSON 值 | 节点运行时输入。 |
| `data.run.runtime_output` | 任意 JSON 值 | 节点运行时输出。 |
| `data.run.runtime_vars` | 任意 JSON 值 | 节点运行时变量。 |
| `data.run.config` | 任意 JSON 值 | 节点运行配置。 |
| `data.run.metrics` | object | 节点指标；服务端提供时返回。 |
| `data.run.developer_logs` | object | 开发日志。可包含 `stdout`、`stderr`、`stream`、字节数、`runner` 和 `output_limited`。 |

## 错误响应

```json
{
  "code": "ErrNotFound",
  "msg": "资源不存在",
  "data": null
}
```

### 常见 HTTP 错误

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP 状态码
  - 错误代码
  - 常见原因
  - 建议操作
* - `400`
  - `ErrParamInvalid`
  - `node_key` 为空或不是有效节点键。
  - 使用工作流 DSL 中的节点键。
* - `401`
  - `ErrUnauthorized`
  - 缺少或无效的访问凭据。
  - 检查 API Key 和工作区 Header。
* - `403`
  - `ErrForbidden`
  - 当前身份没有工作流读取权限。
  - 请求授予 `workflow.read` 权限。
* - `404`
  - `ErrNotFound`
  - 工作流、作业或节点不存在，或节点不属于该作业。
  - 核对三个路径参数。
* - `503`
  - `ErrServiceUnavailable`
  - 依赖服务暂不可用。
  - 稍后重试。
* - `500`
  - `ErrServer`
  - 服务端未能读取节点详情。
  - 稍后重试。
```

## 后续操作

需要从此节点继续执行时，先[查询节点重新运行计划](../workflow-reruns/get-node-rerun-plan.md)。
