[BUG]: Eager Pinecone initialization in vector_store.py crashes backend at import time when PINECONE_API_KEY is not set
@ningyixi ya está trabajando en esto.
Desde el 14/10/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 50/100
Línea de trabajo
Start with the import-time code in backend/app/db/vector_store.py: the PINECONE_API_KEY check, client creation and pc.has_index(INDEX_NAME). Reproduce by running the import snippet from the issue with the key unset, then trace the chain main.py to routes.py to pipeline.py to store_vectors.py. Done means importing app.db.vector_store succeeds without the key, the index is set up on first use, and the non-fatal warning path in store_and_send.py still works.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Fix Eager Pinecone Initialization and Import-Time Failures
Bug Description
In backend/app/db/vector_store.py, Pinecone client initialization, environment validation, and index connection are performed unconditionally at module import time. This causes three reliability issues.
1. Import-Time Failure When PINECONE_API_KEY Is Missing
The module immediately raises an exception when the API key is not configured:
if not PINECONE_API_KEY:
raise ValueError("PINECONE_API_KEY environment variable is required")
Because main.py imports routes.py → pipeline.py → langgraph_builder.py → store_and_send.py → store_vectors.py → vector_store.py, importing the module can crash the entire FastAPI application before any request is handled.
2. Breaks the Non-Fatal Vector Storage Design
In store_and_send.py, the pipeline explicitly documents that vector storage failures should not prevent analysis results from being displayed:
# Vector storage failure is non-fatal to displaying the analysis result
logger.warning(f"Vector storage warning: {storage_err}")
However, when Pinecone initialization fails during module import, the application may never reach the existing error-handling logic. This defeats the intended fallback behavior.
3. Unnecessary Network Requests During Application Startup
The module also performs synchronous network operations, including pc.has_index(INDEX_NAME), at import time.
Network latency, connection failures, or transient timeouts can therefore delay or prevent backend startup, even when vector storage is not immediately required.
Steps to Reproduce
- Open a terminal in the
backenddirectory with the project virtual environment activated. - Ensure
PINECONE_API_KEYis not configured. - Run the following script:
import os
os.environ.pop("PINECONE_API_KEY", None)
import app.db.vector_store
Actual Behavior
Importing app.db.vector_store raises an exception when PINECONE_API_KEY is missing:
ValueError: PINECONE_API_KEY environment variable is required
As a result, modules that depend on the vector store may fail to import, potentially preventing the FastAPI application from starting.
Expected Behavior
- Importing
app.db.vector_storeshould not require immediate Pinecone initialization or network connectivity. - Pinecone client and index initialization should occur lazily when vector storage is actually requested.
- Missing credentials or connection failures should produce clear, descriptive errors at the point of use.
- Vector storage failures should remain non-fatal to analysis generation wherever the existing pipeline explicitly supports that fallback.
- Existing functionality and public interfaces should remain backward-compatible.
Logs and Screenshots
ValueError: PINECONE_API_KEY environment variable is required
Environment Details
- OS: Windows / Linux / macOS
- Python: 3.13
- File:
backend/app/db/vector_store.py - Key packages:
pinecone
Impact
Severity: Medium — Vector storage failures can prevent application startup, even though the application is designed to handle such failures without interrupting analysis generation.
Proposed Solution
- Introduce a lazy
get_index()helper that initializes the Pinecone client and connects to the index only when needed. - Move environment validation and network operations out of module-level execution.
- If backward compatibility requires existing module-level index access, consider implementing module-level
__getattr__to resolve the index lazily. - Preserve the existing vector storage interface wherever possible.
- Ensure initialization and storage errors are handled by the existing non-fatal fallback in
store_and_send.pywithout masking unrelated application errors.
Code of Conduct
- I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there.
- I have searched existing issues to avoid duplicates.
- Lenguaje dominante
- TypeScript
- Estrellas
- 58
- Forks
- 90
- Merge medio
- 11 h 51 min
- PR fusionados (30 d)
- 3
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de AOSSIE-Org/Perspective
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
AOSSIE-Org/Perspective#191 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
AOSSIE-Org/Perspective#190 ·
-
[BUG]: Missing input validation in URlRequest and ChatQuery causes 500 crashes and wasteful scraper executionPosiblemente ocupada @agarwalpranav0711 la tomó hace 25 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
AOSSIE-Org/Perspective#178 ·
-
[BUG]: chunk_rag_data crashes with ValueError when perspective is a dict, silently dropping RAG vector storagePosiblemente ocupada @agarwalpranav0711 la tomó hace 36 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
AOSSIE-Org/Perspective#175 ·
-
[BUG]: Scraper passes headers as query params in requests.get (User-Agent never sent)Posiblemente ocupada @Th-Shivam la tomó hace 50 días. Abiertobug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
AOSSIE-Org/Perspective#161 · 1 comentario ·
Todos los issues de AOSSIE-Org/Perspective
Issues similares
-
documentation lens:human needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
thebristolsound/birdbrain#2246 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
A voting window past about 69.9 million hours stores a deadline that reads back as no deadlineAbiertobug ready-for-human
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
BoardGamesEmpire/board-games-empire-backend#1452 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
good first issue stretch
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día