feat(azure.ai.connections): add --metadata flag to update command - #8475
Merged
Conversation
Adds --metadata key=value flag (repeatable) to 'connection update' so users can set or merge metadata on existing connections without recreating them. Fixes #8470 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Nathandrake229
requested review from
JeffreyCA,
therealjohn,
trangevi and
trrwilson
as code owners
May 29, 2026 08:36
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a repeatable --metadata key=value flag to azd ai connection update so users can merge metadata onto an existing Foundry connection without recreating it. The flag is recorded via a metadataChanged sentinel, included in the "no fields to update" validation, and merged on top of existing metadata before the body is rebuilt and PUT through either the raw REST or ARM SDK path.
Changes:
- Added
metadata/metadataChangedfields and flag registration onconnectionUpdateCommand, and surfaced--metadatain the help/examples. - Included
--metadatain the no-fields-to-update validation message and predicate. - Merged user-supplied metadata pairs after existing metadata when reconstructing the update body.
- Added two validation tests: one for the missing-fields suggestion text and one for metadata-only update.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.connections/internal/cmd/connection.go | Adds --metadata flag wiring, validation, and merge logic to the update command; refreshes help/examples. |
| cli/azd/extensions/azure.ai.connections/internal/cmd/connection_test.go | Adds tests asserting the updated no-fields suggestion and that metadata-only invocations pass validation. |
The update flow for OAuth2 connections was missing the credentials object in the PUT body, causing 400 'Credentials Property can't be empty for auth type OAuth2'. This is the same bug as #8469 but in the update path rather than create. Fixes #8469 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…PR review - Add rawGetConnection() to retrieve full OAuth2 properties (connectorName, authorizationUrl, tokenUrl, scopes, etc.) before update PUT, preventing silent field stripping on metadata/target updates. - Preserve existing credentials via clientIDOrEmpty/clientSecretOrEmpty helpers on rawCredentials. - Add require.Error guard before err.Error() in test to prevent nil panic. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
therealjohn
approved these changes
May 29, 2026
trangevi
approved these changes
May 29, 2026
Member
|
/check-enforcer override |
trangevi
enabled auto-merge (squash)
May 29, 2026 17:24
Copilot AI
added a commit
that referenced
this pull request
Jun 5, 2026
Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>
trangevi
added a commit
that referenced
this pull request
Jun 5, 2026
…connections (#8546) * Initial plan * chore(connections): prepare 0.1.1-preview patch release for azure.ai.connections Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com> * chore(connections): consolidate #8475 changelog entry for 0.1.1-preview Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: trangevi <26490000+trangevi@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two issues in the
azure.ai.connectionsextension:updatemissing--metadataflag — blocks gateway_connector register-actions #8470 —connection updatecommand missing--metadataflagcreate --auth-type oauth2 --connector-namedrops emptycredentialsand fails with 400 #8469 — OAuth2 update path drops emptycredentials, causing400 ValidationErrorFix 1: Add
--metadataflag toconnection update(#8470)Problem: The
updatecommand only supported--target,--key, and--custom-key. There was no way to update metadata on an existing connection without deleting and recreating it. This blocked gateway_connector workflows that requiretype=gateway_connectormetadata.Changes:
metadata []stringandmetadataChanged booltoconnectionUpdateFlagsstruct--metadataas a valid update field--metadatavalues are merged on top of existing metadata (PUT-based update)--metadata key=valueflag (repeatable viaStringArrayVar)Usage:
Fix 2: Emit empty credentials on OAuth2 update path (#8469)
Problem: The
createpath was already fixed (buildOAuth2Credentialsensures"credentials": {}is present for OAuth2), but theupdatepath was not callingbuildOAuth2Credentials. Any update to an OAuth2 connection (e.g., changing target or metadata) failed with:Root cause: The update flow does GET → merge → PUT. The PUT body for OAuth2 connections was constructed without a
Credentialsfield, andomitemptydropped it from the JSON. The ARM API requires"credentials": {}even when empty.Fix: Added
buildOAuth2Credentials(normalizedAuth, "", "")to the raw REST update path, ensuring the empty credentials object is always present for OAuth2 connections.Testing
Unit tests
TestUpdateValidation_NoFieldsToUpdate— verifies error message mentions--metadataTestUpdateValidation_MetadataAloneIsValid— verifies metadata-only update passes validationgo test ./... -count=1)Live validation
Tested against
e2e-tests-ncusproject:create --auth-type oauth2 --connector-name box(no client creds)update --metadata "env=production"(metadata-only on OAuth2 conn)showconfirms merged metadata (type+env)deletecleanupFiles changed
cli/azd/extensions/azure.ai.connections/internal/cmd/connection.gocli/azd/extensions/azure.ai.connections/internal/cmd/connection_test.goFixes #8470
Fixes #8469