ZhuLinsen/daily_stock_analysis · error · ValueError
invalid {field_name} JSON
Error message
invalid {field_name} JSON What it means
Error "invalid {field_name} JSON" thrown in ZhuLinsen/daily_stock_analysis.
Source
Thrown at src/services/history_service.py:503
),
raw_result=self._parse_diagnostic_json_field(
getattr(record, "raw_result", None),
"raw_result",
),
)
@staticmethod
def _parse_diagnostic_json_field(value: Any, field_name: str) -> Any:
"""Strict JSON parser for persisted diagnostic inputs."""
if value is None:
return None
if isinstance(value, str):
if not value.strip():
return None
try:
return json.loads(value)
except (json.JSONDecodeError, TypeError, ValueError) as exc:
raise ValueError(f"invalid {field_name} JSON") from exc
return value
def get_history_detail_by_id(self, record_id: int) -> Optional[Dict[str, Any]]:
"""
Get history report detail.
Uses database primary key for precise query, avoiding returning incorrect records
due to duplicate query_id in batch analysis.
Args:
record_id: Analysis history record primary key ID
Returns:
Complete analysis report dictionary, or None if not exists
"""
try:
record = self.db.get_analysis_history_by_id(record_id)
if not record:View on GitHub (pinned to 5159bd72e8)
Solutions
- Ensure the named field contains valid JSON text before saving or parsing.
- Fix the stored record: re-save the field as serialized JSON rather than a Python repr or truncated string.
- If the field should be optional, pass null/empty instead of malformed JSON.
When it happens
Trigger: Thrown at src/services/history_service.py:503 when the library encounters an invalid state.
Common situations: Raised when a JSON field stored on a history record cannot be parsed; occurs when legacy or corrupted rows contain malformed JSON in raw_result or related fields.
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/1432da44d10670db.
Report an issue: GitHub.