azure-search-openai-demo icon indicating copy to clipboard operation
azure-search-openai-demo copied to clipboard

Error when uploading files after setting environment variables

Open Thomasbjerke opened this issue 1 year ago • 1 comments
trafficstars

Please provide us with the following information:

I have tried setting environment variables for enabling login and document level access control, as well as user document upload (also made sure i had sufficient permissions to create Entra apps in Azure). The problem is that when logging in and uploading a file, i get error "Error uploading file - please try again or contact admin". This happens regardless of file size and file name. The file is uploaded to storage account, but the data does not appear in the index, and the chatbot is not able to answer questions with info from the uploaded file. I have tried both with and without integrated vectorization.

This issue is for a: (mark with an x)

- [ x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

  1. Set these environment variables:
  • azd env set AZURE_USE_AUTHENTICATION true

  • azd env set AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS true

  • azd env set AZURE_ENABLE_UNAUTHENTICATED_ACCESS true

  • azd env set AZURE_AUTH_TENANT_ID <YOUR-TENANT-ID>

  • azd auth login --tenant-id <YOUR-TENANT-ID>

  • azd env set USE_USER_UPLOAD true

I get the same error whether i use integrated vectorization or not.

  1. Run azd up

Any log messages given by the failure

"Error uploading file - please try again or contact admin"

Expected/desired behavior

No error and the chatbot should be able to answer questions using the uploaded files.

azd version?

1.10.3


Thanks! We'll be in touch soon.

Thomasbjerke avatar Nov 01 '24 13:11 Thomasbjerke

@Thomasbjerke Can you look through the server logs and find the corresponding error that happens on the server? The user-facing errors don't bubble up the server error, for security reasons, so you need to check server logs for full error and traceback. Can you also try running locally and seeing if you can replicate the error locally? That can often be easier than sifting through the server logs.

pamelafox avatar Nov 01 '24 19:11 pamelafox

@pamelafox Here is the error message from log stream:

2024-11-05 09:36:59,030 - ERROR - Exception on request POST /upload Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/quart/app.py", line 1403, in handle_request return await self.full_dispatch_request(request_context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/quart/app.py", line 1441, in full_dispatch_request result = await self.handle_user_exception(error) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/quart/app.py", line 1029, in handle_user_exception raise error File "/usr/local/lib/python3.11/site-packages/quart/app.py", line 1439, in full_dispatch_request result = await self.dispatch_request(request_context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/quart/app.py", line 1535, in dispatch_request return await self.ensure_async(handler)(**request_.view_args) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/decorators.py", line 53, in auth_handler return await route_fn(auth_claims) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/app.py", line 365, in upload await ingester.add_file(File(content=file_io, acls={"oids": [user_oid]}, url=file_client.url)) File "/app/prepdocslib/filestrategy.py", line 127, in add_file await self.search_manager.update_content(sections, url=file.url) File "/app/prepdocslib/searchmanager.py", line 297, in update_content await search_client.upload_documents(documents) File "/usr/local/lib/python3.11/site-packages/azure/search/documents/aio/_search_client_async.py", line 578, in upload_documents results = await self.index_documents(batch, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/azure/core/tracing/decorator_async.py", line 105, in wrapper_use_tracer return await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/azure/search/documents/aio/_search_client_async.py", line 677, in index_documents return await self._index_documents_actions(actions=batch.actions, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/azure/search/documents/aio/_search_client_async.py", line 685, in _index_documents_actions batch_response = await self._client.documents.index(batch=batch, error_map=error_map, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/azure/core/tracing/decorator_async.py", line 105, in wrapper_use_tracer return await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/azure/search/documents/_generated/aio/operations/_documents_operations.py", line 857, in index raise HttpResponseError(response=response, model=error) azure.core.exceptions.HttpResponseError: () The request is invalid. Details: Cannot find nested property 'oids' on the resource type 'search.documentFields'. Code: Message: The request is invalid. Details: Cannot find nested property 'oids' on the resource type 'search.documentFields'.

Thomasbjerke avatar Nov 05 '24 09:11 Thomasbjerke

I tried running these after deploying:

python ./scripts/manageacl.py -v --acl-action enable_acls python ./scripts/manageacl.py -v --acl-action update_storage_urls --url <https://YOUR-MAIN-STORAGE-ACCOUNT.blob.core.windows.net/content/>

And it works now.

Thomasbjerke avatar Nov 07 '24 11:11 Thomasbjerke

I tried running these after deploying:

python ./scripts/manageacl.py -v --acl-action enable_acls python ./scripts/manageacl.py -v --acl-action update_storage_urls --url <https://YOUR-MAIN-STORAGE-ACCOUNT.blob.core.windows.net/content/>

And it works now.

@pamelafox I ran these scripts and I am able to upload files as the person who deployed the application but other users get this error when trying to upload files.

The below error is for more context: image

yasirG90 avatar Nov 20 '24 14:11 yasirG90