Warn before initializing from archived template repositories - #9541
Warn before initializing from archived template repositories#9541Victor Vazquez (vhvb1989) wants to merge 4 commits into
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 20 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Detect archived GitHub repositories before cloning templates and require an explicit, default-No confirmation. Preserve safe non-interactive behavior and document GitHub metadata authentication variables. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 254ebc9e-ea83-47b8-b307-309ba40685f4
Mark the archived-template decline sentinel as handled by azd init so the package-level telemetry mapping guard recognizes the intentional control-flow error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 254ebc9e-ea83-47b8-b307-309ba40685f4
Update the template initialization functional test to explicitly accept the archived repository warning before supplying the environment name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 254ebc9e-ea83-47b8-b307-309ba40685f4
|
Azure Pipelines: Successfully started running 1 pipeline(s). 20 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
85a1e20 to
e94e7c8
Compare
There was a problem hiding this comment.
Pull request overview
Adds archived GitHub template detection before cloning and safely handles user cancellation.
Changes:
- Queries GitHub repository metadata with authentication and timeout support.
- Warns and requests default-No confirmation for archived templates.
- Cleans created directories and documents relevant environment variables.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
docs/reference/environment-variables.md |
Documents GitHub metadata variables. |
cli/azd/test/functional/init_test.go |
Accepts the archived-template prompt. |
cli/azd/internal/repository/repository_status.go |
Implements GitHub metadata lookup. |
cli/azd/internal/repository/repository_status_test.go |
Tests lookup and confirmation behavior. |
cli/azd/internal/repository/initializer.go |
Adds pre-clone archive confirmation. |
cli/azd/internal/cmd/errors_test.go |
Classifies the cancellation error. |
cli/azd/docs/environment-variables.md |
Adds detailed variable documentation. |
cli/azd/cmd/init.go |
Handles cancellation and directory cleanup. |
cli/azd/cmd/init_test.go |
Tests cancellation cleanup. |
cli/azd/cmd/container.go |
Registers the metadata checker. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Kristen Womack (@kristenwomack) Hiyo Shin (@hyoshis) - this is the UX - preview
You can install azd from this PR to try it out. You can use this template archived template: |
Use GitHub Cloud tokens and API endpoints for ghe.com tenancy hosts while retaining Enterprise Server tokens and /api/v3 endpoints for configured server hosts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 254ebc9e-ea83-47b8-b307-309ba40685f4
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
cli/azd/internal/repository/initializer.go:218
- azd-code-reviewer: The checker's own 5-second timeout also produces
context.DeadlineExceeded, so this branch abortsazd initinstead of degrading to the existing clone behavior. Propagate cancellation/deadlines only when the caller'sctxis done; treat an internally imposed metadata timeout like the other lookup failures.
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return err
| return fmt.Errorf( | ||
| "template repository %s is archived and requires confirmation; rerun without --no-prompt", | ||
| templateURL, | ||
| ) |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|

Summary
azd init --templaterepository[y/N]confirmation--no-promptmode and clean up auto-created project directories when the user declinesUser experience
Metadata checks use a bounded timeout and degrade to the existing clone behavior when GitHub metadata cannot be retrieved. Context cancellation is still propagated.
Validation
go test ./internal/repository ./cmd -run 'TestGitHubRepositoryStatusChecker|TestInitializerConfirmArchivedTemplate|TestInitArchivedTemplateDeclinedCleansCreatedDirectory|Test_Initializer_Initialize'go test ./internal/repositorygo build ./...golangci-lint run ./internal/repository/... ./cmd/...--no-promptagainstAzure-Samples/todo-csharp-sql-swa-func; initialization stopped before cloning and left the working directory unchangedCloses #9540