Azure / Azure/azure-search-vector-samples

cast(TokenCredential, self._credential).get_token(*scopes, **kwargs) | AttributeError: 'str' object has no attribute 'get_token'

Open
#271 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
910
Forks
377
PR merge metrics
No merged PRs in 30d

Description

pip packages:

```
azure-identity==1.18.0
azure-search-documents==11.6.0b5
azure-storage-blob==12.23.1
```

---------

I am getting following error for the following line under `azure-search-integrated-vectorization.py` file:

```
index = SearchIndex(name=index_name, fields=fields, vector_search=vector_search, semantic_search=semantic_search)
```

How could I fix it?

```python
PS C:\Users\BIM3417\GitHub\bim-chatbot\bot> python.exe .\azure-search-integrated-vectorization.py
vectorizer is not a known attribute of class and will be ignored
resource_uri is not a known attribute of class and will be ignored
deployment_id is not a known attribute of class and will be ignored
Traceback (most recent call last):
File "C:\Users\BIM3417\GitHub\bim-chatbot\bot\azure-search-integrated-vectorization.py", line 177, in
result = index_client.create_or_update_index(index)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\core\tracing\decorator.py", line 94, in wrapper_use_tracer
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\search\documents\indexes\_search_index_client.py", line 276, in create_or_update_index
result = self._client.indexes.create_or_update(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\core\tracing\decorator.py", line 94, in wrapper_use_tracer
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\search\documents\indexes\_generated\operations\_indexes_operations.py", line 692, in create_or_update
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\core\pipeline\_base.py", line 229, in run
return first_node.send(pipeline_request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\core\pipeline\_base.py", line 86, in send
response = self.next.send(request)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\core\pipeline\_base.py", line 86, in send
response = self.next.send(request)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\core\pipeline\_base.py", line 86, in send
response = self.next.send(request)
^^^^^^^^^^^^^^^^^^^^^^^
[Previous line repeated 2 more times]
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\core\pipeline\policies\_redirect.py", line 197, in send
response = self.next.send(request)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\core\pipeline\policies\_retry.py", line 532, in send
response = self.next.send(request)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\core\pipeline\policies\_authentication.py", line 145, in send
self.on_request(request)
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\core\pipeline\policies\_authentication.py", line 120, in on_request
self._request_token(*self._scopes)
File "C:\Users\BIM3417\AppData\Local\Programs\Python\Python312\Lib\site-packages\azure\core\pipeline\policies\_authentication.py", line 96, in _request_token
self._token = cast(TokenCredential, self._credential).get_token(*scopes, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'get_token'
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with azure-search-integrated-vectorization.py and the listed Azure package versions, then trace how the client credential is constructed before create_or_update_index runs. Reproduce the script and verify that the index creation path receives the expected credential type and no longer raises the reported AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, python
Domain
backend, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.