Skip to content

Commit 9e51bbd

Browse files
committed
FIX: Reconcile explicit auth_mode with the get_auth_mode_parameters hook
PR #2846 landed the AzureBlobStorageTarget half of this bug using a get_auth_mode_parameters classmethod. Adopt that hook as the single mechanism for carrying auth intent into target construction and drop the _accepts_auth_mode signature introspection, which only existed because AzureBlobStorageTarget lacked the parameter. Every target advertising identity support now overrides the hook, guarded by a registry-wide contract test so a future identity target cannot silently fall back to inferring auth from a missing key. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 0c780de commit 9e51bbd

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎doc/code/setup/1_configuration.ipynb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
")\n",
213213
"```\n",
214214
"\n",
215-
"`auth_mode` defaults to `\"api_key\"`, which preserves the resolution order above. It is supported by the OpenAI targets, `AzureMLChatTarget`, and `PromptShieldTarget`."
215+
"On the OpenAI targets, `AzureMLChatTarget`, and `PromptShieldTarget`, `auth_mode` defaults to `\"api_key\"`, which preserves the resolution order above. `AzureBlobStorageTarget` accepts the same `auth_mode=\"identity\"` to bypass its SAS token sources; it defaults to selecting a credential automatically."
216216
]
217217
},
218218
{

‎doc/code/setup/1_configuration.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
# )
123123
# ```
124124
#
125-
# `auth_mode` defaults to `"api_key"`, which preserves the resolution order above. It is supported by the OpenAI targets, `AzureMLChatTarget`, and `PromptShieldTarget`.
125+
# On the OpenAI targets, `AzureMLChatTarget`, and `PromptShieldTarget`, `auth_mode` defaults to `"api_key"`, which preserves the resolution order above. `AzureBlobStorageTarget` accepts the same `auth_mode="identity"` to bypass its SAS token sources; it defaults to selecting a credential automatically.
126126

127127
# %% [markdown]
128128
# ## Choosing a database

‎tests/unit/registry/test_target_registry.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,15 @@ def test_credential_parameters_are_sensitive(self, registry: TargetRegistry) ->
446446
)
447447
if looks_like_credential:
448448
assert parameter.sensitive, f"{name}.{parameter.name} looks like a credential"
449+
450+
def test_identity_targets_accept_an_explicit_auth_mode(self, registry: TargetRegistry) -> None:
451+
# Advertising identity support without accepting the explicit mode would silently
452+
# fall back to inferring auth from a missing key, which is the ambiguity the
453+
# explicit auth_mode contract exists to remove.
454+
for name in registry.get_class_names():
455+
target_cls = registry.get_class(name)
456+
if "identity" not in target_cls.supported_auth_modes:
457+
continue
458+
assert target_cls.get_auth_mode_parameters(auth_mode="identity") == {"auth_mode": "identity"}, (
459+
f"{name} advertises identity support but does not forward an explicit auth_mode"
460+
)

0 commit comments

Comments
 (0)