Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Could not find field "%24alt" in the type "google.cloud.aiplatform.v1beta1.FindNeighborsRequest".

Hello! Here goes my first post here!

I am new to Vertex AI and I am going through the tutorial: " Generative AI Knowledge Base".

This is a jumpstart and step by step tutorial that leads to Collab notebook on the tutorial "Upload documents for Generative AI Knowledge Base". https://cloud.google.com/architecture/ai-ml/generative-ai-knowledge-base

The notebook code run then fails with: 

Could not find field "%24alt" in the type "google.cloud.aiplatform.v1beta1.FindNeighborsRequest".

This is coming from the code that uses the VERTEX API, to find the closest embeddings to a given embedding from the Vector Search index endpoint.

I have run the update of the !pip install google-cloud-aiplatform --upgrade and restarted the kernel without luck.

Any advice please ?

 
---------------------------------------------------------------------------
BadRequest                                Traceback (most recent call last)
<ipython-input-32-3eacc1c8e77d> in <cell line: 0>()
     22 
     23 # Query the Vector Search index for the most relevant page.
---> 24 (filename, page_number) = find_document(question, index_endpoint_id, deployed_index_id)
     25 print(f"{filename=} {page_number=}")


5 frames
<ipython-input-32-3eacc1c8e77d> in find_document(question, index_endpoint_id, deployed_index_id)
     11     print(f"Endpoint: {endpoint}")
     12 
---> 13     point = endpoint.find_neighbors(     14         deployed_index_id=deployed_index_id,
     15         queries=[embedding],

/usr/local/lib/python3.11/dist-packages/google/cloud/aiplatform/matching_engine/matching_engine_inde... in find_neighbors(self, deployed_index_id, queries, num_neighbors, filter, per_crowding_attribute_neighbor_count, approx_num_neighbors, fraction_leaf_nodes_to_search_override, return_full_datapoint, numeric_filter, embedding_ids, signed_jwt, psc_network)
   1698             find_neighbors_request.queries.append(find_neighbors_query)
   1699 
-> 1700         response = self._public_match_client.find_neighbors(find_neighbors_request)
   1701 
   1702         # Wrap the results in MatchNeighbor objects and return

/usr/local/lib/python3.11/dist-packages/google/cloud/aiplatform_v1beta1/services/match_service/clien... in find_neighbors(self, request, retry, timeout, metadata)
    797 
    798         # Send the request.
--> 799         response = rpc(    800             request,
    801             retry=retry,

/usr/local/lib/python3.11/dist-packages/google/api_core/gapic_v1/method.py in __call__(self, timeout, retry, compression, *args, **kwargs)
    129             kwargs["compression"] = compression
    130 
--> 131         return wrapped_func(*args, **kwargs)
    132 
    133 

/usr/local/lib/python3.11/dist-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     74     def error_remapped_callable(*args, **kwargs):
     75         try:
---> 76             return callable_(*args, **kwargs)
     77         except grpc.RpcError as exc:
     78             raise exceptions.from_grpc_error(exc) from exc

/usr/local/lib/python3.11/dist-packages/google/cloud/aiplatform_v1beta1/services/match_service/trans... in __call__(self, request, retry, timeout, metadata)
    601             # subclass.
    602             if response.status_code >= 400:
--> 603                 raise core_exceptions.from_http_response(response)
    604 
    605             # Return the response

BadRequest: 400 POST https://924703878.us-central1-391476908846.vdb.vertexai.goog/v1beta1/projects/391476908846/locations...: Could not find field "%24alt" in the type "google.cloud.aiplatform.v1beta1.FindNeighborsRequest".

 

Thank you

1 3 462
3 REPLIES 3

Hi @jonisf8,

Welcome to Google Cloud Community!

It seems you're facing a BadRequest error while working with the Vertex AI tutorial. This type of error typically suggests there's a problem with the request being made to the API.

Here are a few steps you can try to resolve this issue:

  1. Update Everything: Ensure you're using the latest versions of all Vertex AI-related libraries and tools in your environment. This often resolves hidden bugs. You can also visit Vertex AI release notes to check if a recent update might be related to your issue.
  2. Inspect the Raw Request: Examine the exact data your code is sending to the Vertex AI API. Print or log the request content to look for unexpected elements (especially %24alt or similar characters) that the API doesn't recognize.
  3. Minimum Viable Request: Create a simple request containing only the absolutely essential information required by the API. If this works, gradually add back features until the error reappears, pinpointing the problem.
  4. Data Format Verification: Confirm that all data you're sending (numbers, strings, etc.) matches the API's expected format. Incorrect formatting can lead to parsing errors.
  5. Authentication Check: Verify that you are correctly authenticated with your Google Cloud account and have the necessary permissions to access the Vertex AI service.
  6. Rebuild the Environment: Try recreating your Vertex AI index and endpoint from scratch. This can eliminate configuration issues that are difficult to trace.
  7. Example Comparison: Compare your request structure and data to a known working example. This helps identify discrepancies that might be causing the error.

You can also visit the following documentation for more details:

Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.

Having the same issue with the "Generative AI KnowledgeBase" jumpstart solution as of today, finally found a fix! 

1. switching to gRPC over REST appeared to fix the bad url parameters. In the initialization step of the notebook, add the `api_transport='grpc'` argument to your ai platform init, it should look like this:

 

 

import vertexai
from google.cloud import aiplatform

vertexai.init(location=location)
aiplatform.init(location=location, api_transport='grpc')

 

 

 2. I noticed the project ID in my deployed endpoint was different then my regular project. Go to your Deployed Endpoint and check it's slug for the correct project ID if you're still having issues. 

Looks like the notebook from Github hasn't been updated to reflect recent changes in the python ai platform library. Might have to make a pull request if this fix works for others 😅

Thank you! I had to stop trying this for a while but I'll get back to it and Accept as Solution when i do it