Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

extract fails when a policy uses set-backend-service backend-id="{{namedValue}}"

未關閉 適合新手
#331 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 3 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
azure, typescript
領域
api, backend

研究方向

從 src/services/transitive-resolver.ts 開始,issue 在這裡指出了 BACKEND_PATTERN 和 scanPolicyReferences;追蹤擷取到的 backend ID 如何註冊為傳遞相依項。檢查相關的 transitive resolver 測試,並為 backend-id 中的具名值佔位符新增涵蓋。完成標準是擷取程序會略過該佔位符,不將它視為字面 Backend 名稱,且測試確認不會出現誤報的缺少 backend 錯誤。

由索引模型根據 Issue 內容生成。

描述

type:bug
Command that triggered the bug

apiops extract

Expected behavior

A policy that references a backend through a named value is valid in APIM:

<set-backend-service backend-id="{{demo-backend-id}}" />

extract should not treat the placeholder {{demo-backend-id}} as the name of a Backend resource. Extraction should finish with 0 errors and exit code 0 when every real resource exists.

Actual behavior

BACKEND_PATTERN in src/services/transitive-resolver.ts is:

const BACKEND_PATTERN = /<set-backend-service\s+backend-id="([^"]+)"/g;

It captures the raw attribute value including braces, so {{demo-backend-id}} is registered as a transitive dependency of type Backend with the literal name {{demo-backend-id}}. APIM has no such backend, so the GET 404s, the error counter is incremented, and the run exits 1:

[INFO] Resolving transitive dependencies for workspace "[ws name]"...
[INFO] Found 1 transitive dependencies to extract
[WARN] Transitive dependency backends/{{demo-backend-id}} was not found
[INFO] Workspace "[ws name]": extracted 32 resources, 1 errors
[INFO] Extraction complete: 33 resources extracted, 1 errors
Total: 33 resources extracted, 1 errors in 19.8s
##[error]Script failed with exit code: 1

The false error fails the pipeline step. The extracted files are written locally, but the pipeline stops before the "publish artifacts" task, so nothing is committed or published and no PR branch is created.

Since 1.0.5 (#319) the 404 is logged as a warning. Before that, the same case produced no log line at all, only the error count. The exit code 1 is unchanged.

Using the literal Backend name (backend-id="backend-xyz") instead of the named-value placeholder avoids the error. That workaround conflicts with our planned move to Backend entities referenced via named values, so this blocks our extract pipeline.

Observed in a workspace-scoped extract, but the code path is not workspace-specific: BACKEND_PATTERN/scanPolicyReferences and extractTransitiveDependencies are shared with the service-level extract in extract-service.ts, so I expect the same behavior at instance level (not tested).

Minimal repro:

  1. Create a Backend backend-xyz and a Named Value demo-backend-id with value backend-xyz.
  2. Add <set-backend-service backend-id="{{demo-backend-id}}" /> to an API policy in the extracted scope.
  3. Run apiops extract with transitive resolution on (default).
  4. Observe the false error and exit 1.

Likely the same problem for (from reading the regex, not tested):

  • backend-id="@(...)" policy expressions (also not a literal Backend name).
  • Commented-out <set-backend-service> elements — see #305.

Related: #276 / PR #290 (same bug class for Liquid {{ }} in NAMED_VALUE_PATTERN; leaves BACKEND_PATTERN untouched), #291 / PR #319 (named-value displayName 404s; added the "not found" warning)

apiops CLI version

1.0.5

Environment details
  • Azure DevOps pipeline, Microsoft-hosted agent
  • CLI installed from the v1.0.5 release tarball (@azure-tools/apiops-cli), run via npx apiops
CI/CD environment

Azure DevOps

Is this bug blocking you?

Yes

主要語言
TypeScript
星號
34
分支
13
平均合併
3 天 6 小時
30 天內合併 PR
7

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

Azure/apiops-cli 的其他 Issue

查看 Azure/apiops-cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。