The size of the request headers is too long #39605
Labels
Client
This issue points to a problem in the data-plane of the library.
Cosmos
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Service Attention
Workflow: This issue is responsible by Azure service team.
Describe the bug
Im encountering an HTTP 400 error indicating that the request headers are too large when using the Azure Cosmos DB Python SDK.
To Reproduce
Steps to reproduce the behavior:
import time
import json
import pandas as pd
from azure.identity import DefaultAzureCredential
from azure.cosmos import CosmosClient
logging.basicConfig(level=logging.INFO)
Conexión a Cosmos DB
COSMOS_ENDPOINT = "#####"
DATABASE_NAME = "####"
CONTAINER_NAME = "####"
credential = DefaultAzureCredential()
client = CosmosClient(COSMOS_ENDPOINT, credential=credential)
database = client.get_database_client(DATABASE_NAME)
container = database.get_container_client(CONTAINER_NAME)
Partición (en este caso solo hay una)
PARTITION_KEY_VALUE = "###"
Diccionario para guardar métricas y SQL de cada consulta
metricas_consultas = {}
def ejecutar_consulta(sql_query, parameters=None, partition_key=None,
consulta_nombre="consulta_sin_nombre", descripcion=""):
"""
Ejecuta una consulta en Cosmos DB, mide el tiempo y guarda resultados en metricas_consultas.
"""
start_time = time.time()
# Ejecución de la consulta
results_iter = container.query_items(
query=sql_query,
parameters=parameters or [],
partition_key=partition_key
# NOTA: No se usa enable_cross_partition_query porque se tiene una sola partición.
)
results_list = list(results_iter)
elapsed = time.time() - start_time
Query:
consulta_nombre = "group_by_factor_riesgo"
descripcion = "Agrupa (FACTOR_DE_RIESGO, TIPO_RIESGO) sin filtros"
sql_query = """
SELECT
c.I_GRAVEDAD,
c.I_PROBABILIDAD,
COUNT(1)
FROM c
GROUP BY c.I_GRAVEDAD, c.I_PROBABILIDAD
"""
results = ejecutar_consulta(
sql_query=sql_query,
partition_key=PARTITION_KEY_VALUE,
consulta_nombre=consulta_nombre,
descripcion=descripcion
)
for r in results:
print(r)
Expected behavior
Output 16 results.
Screenshots
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: