Skip to content

fix(toolboxes): skip env-sync gracefully when no azd project exists#9220

Merged
huimiu merged 1 commit into
mainfrom
trangevi/fix-toolbox-create-no-azd-project
Jul 21, 2026
Merged

fix(toolboxes): skip env-sync gracefully when no azd project exists#9220
huimiu merged 1 commit into
mainfrom
trangevi/fix-toolbox-create-no-azd-project

Conversation

@trangevi

Copy link
Copy Markdown
Member

Why

azd ai toolbox create --project-endpoint <url> --from-file <path> fails when run outside an azd project (no azure.yaml). The endpoint resolves fine via the --project-endpoint flag and the toolbox is created on the server, but the post-create step that writes the MCP endpoint to the azd environment crashes because isNoAzdEnvironment() doesn't recognize the "no project exists" gRPC error.

The env-sync is already documented as best-effort -- it should skip silently when there is no azd environment to write to, not fail the entire operation.

Approach

Widened isNoAzdEnvironment() in toolbox_env.go to also match the "no project exists" message that the azd gRPC server returns when GetCurrent() is called without an azure.yaml. This sits alongside the existing "default environment not found" check and the codes.Unavailable check.

Added a corresponding test case to the TestIsNoAzdEnvironment table.

Fixes: #9219

isNoAzdEnvironment() now also matches the 'no project exists' error
from the azd gRPC server, so toolbox create/delete with
--project-endpoint succeeds even without an azure.yaml / azd
environment. The env-sync is already documented as best-effort.

Fixes #9219

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 20, 2026 23:50
@github-actions

Copy link
Copy Markdown

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Thank you for logging this issue; our team is reviewing it. If you need urgent prioritization, tag @RickWinter and @kristenwomack to let us know.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
21 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates toolbox environment synchronization to gracefully skip when no azd project exists.

Changes:

  • Recognizes the host’s “no project exists” gRPC error.
  • Adds unit coverage for the new case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
toolbox_env.go Expands missing-environment detection.
toolbox_env_test.go Tests operation without an azd project.

@github-actions github-actions Bot added the ext-toolboxes azure.ai.toolboxes extension label Jul 20, 2026

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the error path: currentEnvironment resolves the azd context via lazyAzdContext.GetValue(), which returns azdcontext.ErrNoProject with the message "no project exists; to create a new project, run azd init". GetCurrent passes it through and gRPC surfaces it as codes.Unknown, so the widened substring match skips env-sync as intended. Message-matching stays consistent with the azure.ai.agents sibling, and the new test case uses the real error string. Tests pass locally.

@huimiu
huimiu merged commit eae72a4 into main Jul 21, 2026
29 checks passed
@huimiu
huimiu deleted the trangevi/fix-toolbox-create-no-azd-project branch July 21, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-toolboxes azure.ai.toolboxes extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Toolbox Extension] Toolbox creation failing with existing project

4 participants