Skip to content

Null-guard feedKeys/feedOverrides in SetupTargetFeedConfigV3 (fixes NRE on keyless Entra publish)#17188

Open
missymessa wants to merge 1 commit into
dotnet:mainfrom
missymessa:null-guard-feedkeys
Open

Null-guard feedKeys/feedOverrides in SetupTargetFeedConfigV3 (fixes NRE on keyless Entra publish)#17188
missymessa wants to merge 1 commit into
dotnet:mainfrom
missymessa:null-guard-feedkeys

Conversation

@missymessa

Copy link
Copy Markdown
Member

Null-guard feedKeys/feedOverrides in SetupTargetFeedConfigV3

SetupTargetFeedConfigV4 already guards these parameters against null, but SetupTargetFeedConfigV3 does not. When Build Promotion publishes with Entra/WIF auth and no feed key, the FeedKey MSBuild item is empty, so the task's FeedKeys parameter arrives null and .ToImmutableDictionary() throws before auth runs:

PublishArtifactsInManifest.proj(129,5): error : Value cannot be null. (Parameter 'source')
   at ...SetupTargetFeedConfigV3..ctor line 74

This change makes V3 match V4: a null feedKeys/feedOverrides yields an empty dictionary and the publisher falls back to Entra auth as intended. It does not change any current publishing behavior on its own — the key-based path is unaffected.

Why now

Keyless Build Promotion (#17185) hit this exact crash in production (roslyn 3030919, dnceng-shared 3030947) and was reverted by #17186. This is the task-level fix that makes keyless safe.

Rollout

This is step 2 of the durable rollout:

  1. Revert #17185: restore AzureDevOpsFeedsKey (task NREs on null FeedKeys, breaking prod promotions) #17186 (revert) — unblock prod. ✅
  2. This PR — null-guard the task.
  3. New arcade SDK builds with the fix; global.json bump flows it into Build Promotion.
  4. Re-apply keyless publish.yml (follow-up PR) once the fixed task is live.

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

This PR fixes a null-reference crash in the Microsoft.DotNet.Build.Tasks.Feed publishing task by making SetupTargetFeedConfigV3 tolerate null feedKeys/feedOverrides inputs (which can occur when the corresponding MSBuild ItemGroup is empty), aligning its behavior with SetupTargetFeedConfigV4 for keyless Entra/WIF publishing scenarios.

Changes:

  • Null-guard feedKeys and feedOverrides before converting them to immutable dictionaries in SetupTargetFeedConfigV3.
  • Add explanatory comments documenting why these parameters can be null in MSBuild task binding.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +74 to +77
// feedKeys/feedOverrides may be null when the corresponding MSBuild ItemGroup is empty
// (e.g. when publishing with Entra/WIF auth and no feed key is supplied).
FeedKeys = (feedKeys ?? Array.Empty<ITaskItem>()).ToImmutableDictionary(i => i.ItemSpec, i => i.GetMetadata("Key"));
FeedOverrides = (feedOverrides ?? Array.Empty<ITaskItem>()).ToImmutableDictionary(i => i.ItemSpec, i => i.GetMetadata("Replacement"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants