[BUG]: chunk_rag_data crashes with ValueError when perspective is a dict, silently dropping RAG vector storage
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
Direzione di ricerca
Inizia da backend/app/modules/vector_store/chunk_rag_data.py, dove chunk_rag_data() valida data['perspective'] con hasattr() intorno alla riga 61. Esegui lo snippet di riproduzione dell'issue per confermare il ValueError e controlla langgraph_nodes/store_and_send.py per vedere come il dict arriva a questa funzione. Il lavoro è completo quando gli input dict con entrambe le chiavi vengono suddivisi in chunk, le chiavi mancanti sollevano un errore descrittivo e gli input oggetto continuano a funzionare, con unit test che coprano ciascun caso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Fix Perspective Validation for Dictionary Inputs in chunk_rag_data
Bug Description
In backend/app/modules/vector_store/chunk_rag_data.py, the chunk_rag_data() function validates the perspective data using hasattr() on data["perspective"].
However, when perspective is provided as a standard Python dictionary, as can happen when deserializing LangGraph pipeline state or JSON payloads, hasattr() returns False for dictionary keys. This causes the function to raise a ValueError even when all required fields are present.
The current validation logic is:
perspective_obj = data["perspective"]
if not (
hasattr(perspective_obj, "perspective")
and hasattr(perspective_obj, "reasoning")
):
raise ValueError("Perspective object missing required fields")
For dictionary inputs, the required fields must be checked using dictionary key access or an equivalent mapping-aware validation approach.
Steps to Reproduce
- Open a terminal in the
backend/directory with the project virtual environment activated. - Run the following Python snippet:
from app.modules.vector_store.chunk_rag_data import chunk_rag_data
sample_state = {
"cleaned_text": "Sample text for chunking and article ID generation.",
"perspective": {
"perspective": "Synthesized counter perspective narrative.",
"reasoning": "Underlying tradeoffs and evidentiary counter-arguments."
},
"facts": [
{
"original_claim": "Claim 1",
"verdict": "Verified",
"explanation": "Evidence description",
"source_link": "https://example.com"
}
]
}
chunk_rag_data(sample_state)
Actual Behavior
The function raises a ValueError even though the perspective dictionary contains both required fields:
ValueError: Perspective object missing required fields
The error is logged by chunk_rag_data() and prevents the supplied data from being processed successfully.
Expected Behavior
- The function should accept perspective data represented as a standard dictionary when the required fields are present.
- Validation should correctly check for the
perspectiveandreasoningkeys in dictionary inputs. - Missing or invalid required fields should produce a descriptive validation error.
- Existing behavior for supported perspective object types should be preserved.
- Valid input should proceed through the normal chunking process.
Logs and Screenshots
[ERROR] [app.modules.vector_store.chunk_rag_data]: Failed to chunk the data: Perspective object missing required fields
Traceback (most recent call last):
File "backend/app/modules/vector_store/chunk_rag_data.py", line 61, in chunk_rag_data
raise ValueError("Perspective object missing required fields")
ValueError: Perspective object missing required fields
Environment Details
- OS: Windows / Linux / macOS
- Python: 3.13
- File:
backend/app/modules/vector_store/chunk_rag_data.py - Related module:
backend/app/modules/langgraph_nodes/store_and_send.py
Impact
Severity: Medium — Valid dictionary-based pipeline state is rejected during chunking, potentially disrupting downstream vector storage and retrieval workflows.
Proposed Solution
- Replace the
hasattr()-only validation with mapping-aware validation for dictionary inputs. - Check that both
perspectiveandreasoningare present and contain valid values before processing. - Preserve compatibility with existing supported object-based inputs, if required.
- Add unit tests covering valid dictionaries, missing fields, invalid values, and supported object inputs.
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.
- Lingua principale
- TypeScript
- Stelle
- 58
- Fork
- 90
- Merge medio
- 11h 51m
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di AOSSIE-Org/Perspective
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
AOSSIE-Org/Perspective#191 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
AOSSIE-Org/Perspective#190 ·
-
[BUG]: Missing input validation in URlRequest and ChatQuery causes 500 crashes and wasteful scraper executionForse già presa @agarwalpranav0711 l’ha presa 25 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
AOSSIE-Org/Perspective#178 ·
-
[BUG]: Scraper passes headers as query params in requests.get (User-Agent never sent)Forse già presa @Th-Shivam l’ha presa 50 giorni fa. Apertabug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
AOSSIE-Org/Perspective#161 · 1 commento ·
-
docs: frontend/README.md is the default create-next-app boilerplateForse già presa @Th-Shivam l’ha presa 51 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
AOSSIE-Org/Perspective#159 · 1 commento ·
Tutte le issue di AOSSIE-Org/Perspective
Issue simili
-
documentation lens:human needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
thebristolsound/birdbrain#2246 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
A voting window past about 69.9 million hours stores a deadline that reads back as no deadlineApertabug ready-for-human
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
BoardGamesEmpire/board-games-empire-backend#1452 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue stretch
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno