[BUG]: chunk_rag_data crashes with ValueError when perspective is a dict, silently dropping RAG vector storage

オープン 初心者向け
#175 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@agarwalpranav0711 がすでに取り組んでいます。

2026年10月15日 から。

  • #176 @agarwalpranav0711 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

backend/app/modules/vector_store/chunk_rag_data.py から始めてください。61行目付近で chunk_rag_data() が hasattr() を使って data['perspective'] を検証している箇所です。Issue の再現スニペットを実行して ValueError を確認し、langgraph_nodes/store_and_send.py を見て dict がこの関数にどう渡されるかを確認してください。両方のキーを持つ dict 入力がチャンク化されること、キーが欠けている場合にわかりやすいエラーが発生すること、オブジェクト入力が引き続き動作することが完了条件です。各ケースをカバーするユニットテストを追加してください。

索引モデルが issue の本文から書いたものです。

説明

bug

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
  1. Open a terminal in the backend/ directory with the project virtual environment activated.
  2. 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 perspective and reasoning keys 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
  1. Replace the hasattr()-only validation with mapping-aware validation for dictionary inputs.
  2. Check that both perspective and reasoning are present and contain valid values before processing.
  3. Preserve compatibility with existing supported object-based inputs, if required.
  4. Add unit tests covering valid dictionaries, missing fields, invalid values, and supported object inputs.
Code of Conduct
主要言語
TypeScript
スター
58
フォーク
90
平均マージ
11時間 51分
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AOSSIE-Org/Perspective のほかの issue

AOSSIE-Org/Perspective の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。