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

Closed Beginner friendly
#690 0 comments 1 reaction 0 assignees View on GitHub

A pull request for this has already been merged.

  • #691 by @magodo — merged

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
azure, go, terraform
Domain
cli

Research direction

The report identifies internal/populate/populate_mssql_job.go:31-32 and the matching line in internal/populate/populate_stream_analytics_job.go:36 in aztft. Read those append operations, then run the resource group listing command described in the issue with the fix built in; done means it exits successfully and exports the listed resources without panicking.

Written by the indexing model from the issue text.

Description

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?

Dominant language
Go
Stars
1.9k
Forks
223
Avg merge
1d 11h
Merged PRs (30d)
4

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Azure/aztfexport

All issues in Azure/aztfexport

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.