Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The size of the request headers is too long #39605

Open
cmilanes93 opened this issue Feb 6, 2025 · 2 comments
Open

The size of the request headers is too long #39605

cmilanes93 opened this issue Feb 6, 2025 · 2 comments
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.

Comments

@cmilanes93
Copy link

  • Azure Cosmos: 4.9.0
  • Python Version: 3.11.9

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:

  1. import logging
    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

# Guardar métricas
metricas_consultas[consulta_nombre] = {
    "pregunta": descripcion,
    "sql_query": sql_query,
    "tiempo_seg": round(elapsed, 4),
    "num_documentos": len(results_list)
}

logging.info(f"[{consulta_nombre}] -> {len(results_list)} resultados en {elapsed:.4f} seg")
return results_list

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

Image

Additional context
Add any other context about the problem here.

@github-actions github-actions bot added 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. labels Feb 6, 2025
Copy link

github-actions bot commented Feb 6, 2025

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AbhinavTrips @bambriz @Pilchie @pjohari-ms @simorenoh.

@Pilchie
Copy link
Member

Pilchie commented Feb 6, 2025

Tagging @kushagraThapar too. Given this is using EntraID, I wonder if the token is too long with claims?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
Status: No status
Development

No branches or pull requests

2 participants