ZhuLinsen/daily_stock_analysis · error · DecisionSignalSourceReportNotFoundError
source_report_not_found
source_report_not_found
Error message
source report not found: {source_report_id} What it means
The reassess flow loads a source analysis report by id via db.get_analysis_history_by_id; a missing record raises DecisionSignalSourceReportNotFoundError (code=source_report_not_found), which the API maps to an HTTP error on the reassess endpoint.
Source
Thrown at src/services/decision_signal_reassess_service.py:72
signal_service: Optional[DecisionSignalService] = None,
) -> None:
self.db = db or DatabaseManager.get_instance()
self.signal_service = signal_service or DecisionSignalService(db_manager=self.db)
def reassess(
self,
*,
source_report_id: int,
decision_profile: str,
persist: bool = False,
) -> dict[str, Any]:
decision_profile_norm = normalize_decision_profile(decision_profile)
if decision_profile_norm is None:
raise ValueError("decision_profile is required")
record = self.db.get_analysis_history_by_id(source_report_id)
if record is None:
raise DecisionSignalSourceReportNotFoundError(f"source report not found: {source_report_id}")
raw_result = _parse_mapping(getattr(record, "raw_result", None))
context_snapshot = _parse_mapping(getattr(record, "context_snapshot", None))
candidate = _build_candidate(record, raw_result, context_snapshot)
data_quality_level = normalize_decision_signal_data_quality(
_first_present(
_nested_get(context_snapshot, ("analysis_context_pack_overview", "data_quality")),
_nested_get(context_snapshot, ("data_quality",)),
_nested_get(raw_result, ("analysis_context_pack_overview", "data_quality")),
_nested_get(raw_result, ("data_quality",)),
)
)
policy = apply_decision_profile_policy(
candidate,
decision_profile=decision_profile_norm,
data_quality_level=data_quality_level,
)
preview_candidate = policy.candidateView on GitHub (pinned to 5159bd72e8)
Solutions
- Confirm the report exists: GET the analysis-history detail endpoint for that id first.
- Use an id from the history list response of the same environment.
- If history was pruned, pick a still-retained report to reassess.
Example fix
# before
result = service.reassess(source_report_id=12345, decision_profile="balanced")
# after
record = db.get_analysis_history_by_id(12345)
if record is None:
raise SystemExit("pick a valid report id from the history list")
result = service.reassess(source_report_id=12345, decision_profile="balanced") Defensive patterns
Strategy: try-catch
Validate before calling
record = db.get_analysis_history_by_id(source_report_id)
if record is None:
return JSONResponse(status_code=404, content={"error": "source_report_not_found", "message": f"report {source_report_id} not found"})
result = service.reassess(source_report_id=source_report_id, decision_profile=profile) Type guard
def isExistingReport(db, report_id: int) -> bool:
return db.get_analysis_history_by_id(report_id) is not None Try / catch
from src.services.decision_signal_reassess_service import DecisionSignalSourceReportNotFoundError
try:
result = service.reassess(source_report_id=rid, decision_profile=profile, persist=persist)
except DecisionSignalSourceReportNotFoundError:
return JSONResponse(status_code=404, content={"error": "source_report_not_found", "message": f"report {rid} not found"}) Prevention
- Only offer reassess on reports returned by the history list of the same environment.
- Handle history-retention pruning: expired ids should 404 gracefully in the UI.
- Validate the id is a positive int before calling.
When it happens
Trigger: POST /api/v1/decision-signals/reassess (preview or persist) with source_report_id that has no row in analysis_history — deleted history, wrong environment DB, or a plain typo in the id.
Common situations: Reassessing old reports after history retention pruned them; ids from a different instance; UI deep links to purged reports.
Related errors
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/03eb9f1f6395ee4d.
Report an issue: GitHub.