extract fails when a policy uses set-backend-service backend-id="{{namedValue}}"
維護者通常 3 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 78/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- azure, typescript
研究方向
從 src/services/transitive-resolver.ts 開始,issue 在這裡指出了 BACKEND_PATTERN 和 scanPolicyReferences;追蹤擷取到的 backend ID 如何註冊為傳遞相依項。檢查相關的 transitive resolver 測試,並為 backend-id 中的具名值佔位符新增涵蓋。完成標準是擷取程序會略過該佔位符,不將它視為字面 Backend 名稱,且測試確認不會出現誤報的缺少 backend 錯誤。
由索引模型根據 Issue 內容生成。
描述
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:
- Create a Backend
backend-xyzand a Named Valuedemo-backend-idwith valuebackend-xyz. - Add
<set-backend-service backend-id="{{demo-backend-id}}" />to an API policy in the extracted scope. - Run
apiops extractwith transitive resolution on (default). - 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 vianpx apiops
CI/CD environment
Azure DevOps
Is this bug blocking you?
Yes
- 主要語言
- TypeScript
- 星號
- 34
- 分支
- 13
- 平均合併
- 3 天 6 小時
- 30 天內合併 PR
- 7
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Azure/apiops-cli 的其他 Issue
-
stale type:question
難度 2/5 1-3 小時 新手友好度 76/100
Azure/apiops-cli#277 · 1 則留言 ·
維護者通常 3 天內回覆
-
stale type:documentation
難度 1/5 1 小時以內 新手友好度 94/100
Azure/apiops-cli#250 · 1 則留言 ·
維護者通常 3 天內回覆
-
Documentation P2 stale
難度 2/5 1-3 小時 新手友好度 70/100
Azure/apiops-cli#24 · 2 則留言 ·
維護者通常 3 天內回覆
-
type:bug
難度 3/5 1-2 天 新手友好度 53/100
Azure/apiops-cli#330 ·
維護者通常 3 天內回覆
-
type:bug
難度 4/5 3-5 天 新手友好度 48/100
Azure/apiops-cli#328 ·
維護者通常 3 天內回覆
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
awslabs/visual-asset-management-system#804 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
restatedev/sdk-typescript#813 ·
-
bug desktop P1 session XS
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
Merit-Systems/x402scan#1312 ·
-
bug effort:S P3
難度 2/5 1-3 小時 新手友好度 72/100
nightscout/nocturne#2840 ·
維護者通常 1 天內回覆