fix: restore netloc-based credential formatting for YAML deployments #19873
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
Fixes #19861
Related: #19296
PR #19236 refactored git credential formatting to move provider-specific logic from
_format_token_from_credentialsintoBlock.format_git_credentials()methods on each integration. This was intended to improve separation of concerns.However, the refactor inadvertently broke YAML deployments that use block references like:
When credentials are specified this way,
resolve_block_document_referencesreturns a dict (expected behavior per @desertaxle), not a Block instance. Since dicts don't implement the_GitCredentialsFormatterprotocol, the formatting logic was skipped entirely, causing GitLab authentication to fail (missingoauth2:prefix).Changes
Restores the netloc-based provider detection in
_format_token_from_credentialsfor dict credentials:gitlabin URL): Addsoauth2:prefix for PATs, handles deploy tokensbitbucketin URL): Addsx-token-auth:prefixbitbucketserverin URL): Requiresusername:tokenformatBlock instances still use the protocol-based
format_git_credentials()method - this change only affects the dict fallback path.Test Plan
Added 4 regression tests covering dict credential formatting for GitLab, BitBucket, and GitHub URLs.
Reproduction script
🤖 Generated with Claude Code