Panic listing a resource group with an Azure SQL Elastic Job agent: invalid input in armid.formatScope

クローズ 初心者向け
#690 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

関連するプルリクエストがすでにマージされています。

  • #691 @magodo による — マージ済み

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
azure, go, terraform
領域
cli

調査の方向性

報告では、aztft の internal/populate/populate_mssql_job.go:31-32 と internal/populate/populate_stream_analytics_job.go:36 の該当行が指摘されています。これらの append 操作を読み、次に修正を組み込んだ状態で、issue に記載されているリソースグループ一覧表示コマンドを実行します。正常終了し、パニックを起こさずに一覧のリソースをエクスポートできれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Version

aztfexport v0.20.0 (d52e1c5), with aztft at v0.3.1-0.20260625235534-b710d5ecffdc.

What happens

Listing a resource group that holds an Azure SQL Elastic Job agent with a scheduled job panics:

aztfexport rg --non-interactive --plain-ui --generate-mapping-file -o <dir> <resource-group>
panic: invalid input: len([servers jobAgents jobs schedules]) != len([servers jobAgents jobs schedules default])

github.com/magodo/armid.formatScope(...)
	github.com/magodo/[email protected]/armid.go:888
github.com/magodo/armid.(*ScopedResourceId).String(...)
	github.com/magodo/[email protected]/armid.go:764
github.com/magodo/aztft/aztft.queryType.func1(...)
	github.com/magodo/[email protected]/aztft/aztft.go:168

The process exits with code 2, so nothing is exported from that resource group.

Cause

In aztft, internal/populate/populate_mssql_job.go:31-32:

sid.AttrTypes = append(sid.AttrTypes, "schedules")
sid.AttrNames = append(sid.AttrTypes, "default")

The second line appends to AttrTypes where AttrNames is meant, so AttrNames ends up one element longer than AttrTypes and String() panics.

internal/populate/populate_stream_analytics_job.go:36 has the same pattern. We have not run that path. Both lines are still present at aztft head (1e6fd26).

Fix we tested

Changing AttrTypes to AttrNames on the right-hand side of both lines, built against the aztft commit above. The same command then exits 0, and the mapping file lists the agent, its jobs, schedules, steps and target groups. Exporting the azurerm_mssql_* resources from that mapping with --hcl-only also runs without a panic.

Could this go into aztft and a new aztfexport release?

主要言語
Go
スター
1.9k
フォーク
223
平均マージ
1日 11時間
マージ済み PR(30日)
4

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Azure/aztfexport のほかの issue

Azure/aztfexport の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。