{"record":{"id":"f4250fd7809aec87","repo":"HKUDS/Vibe-Trading","slug":"evidence-text-cannot-be-empty","errorCode":null,"errorMessage":"evidence text cannot be empty","messagePattern":"evidence text cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/goal/store.py","lineNumber":632,"sourceCode":"            goal_id: Goal being mutated.\n            expected_goal_id: Goal id captured at the start of the agent turn.\n            evidence: Evidence payload.\n\n        Returns:\n            Persisted evidence record.\n\n        Raises:\n            StaleGoalError: If the expected goal id does not match or goal is not current.\n            ValueError: If evidence text is empty or references an unknown criterion.\n        \"\"\"\n        evidence_id = _id(\"ev\")\n        with self._write_transaction():\n            goal = self._require_mutable_goal(session_id, goal_id, expected_goal_id)\n            session_id = goal.session_id\n            goal_id = goal.goal_id\n            text = evidence.text.strip()\n            if not text:\n                raise ValueError(\"evidence text cannot be empty\")\n            if evidence.criterion_id is not None:\n                self._require_criterion(goal.goal_id, evidence.criterion_id)\n            if evidence.claim_id is not None:\n                self._require_claim(goal.goal_id, evidence.claim_id)\n\n            now = _now_iso()\n            freshness_status = \"fresh\" if evidence.data_as_of else \"unknown\"\n            verification_status = self._verification_status(evidence)\n            self._conn.execute(\n                \"\"\"\n                INSERT INTO goal_evidence (\n                    evidence_id, goal_id, session_id, criterion_id, claim_id,\n                    evidence_type, text, tool_call_id, run_id, source_provider,\n                    source_type, source_uri, symbol_universe_json, benchmark_json,\n                    timeframe, method, assumptions_json, artifact_path,\n                    artifact_hash, retrieved_at, data_as_of, freshness_status,\n                    verification_status, confidence, caveat,\n                    contradicts_claim_ids_json, created_at","sourceCodeStart":614,"sourceCodeEnd":650,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/goal/store.py#L614-L650","documentation":"append_evidence strips the evidence text and raises ValueError('evidence text cannot be empty') when nothing remains — an evidence row must carry actual content to be usable in goal audits. The check runs inside a write transaction after the goal is confirmed mutable and IDs resolved.","triggerScenarios":"Calling append_evidence with evidence.text='' or whitespace-only ('   ', '\\n'); agent flows (cmd_evidence / add_goal_evidence) forwarding a file read that came back empty or a generated summary that was blank.","commonSituations":"Automated agents logging evidence from tool output that can be empty; templates producing whitespace-only strings; UI optional textareas submitted empty; tests asserting rejection of blank evidence.","solutions":["Ensure evidence.text is a non-blank string before calling append_evidence","In agent loops, skip logging when the captured output is empty rather than recording it","Strip and check in the caller: if not text.strip(): return/skip","If evidence is genuinely empty (e.g. empty command output), record a descriptive placeholder like '(no output)'"],"exampleFix":"# before\nstore.append_evidence(session_id, goal_id, EvidenceRecord(text=\"   \"))\n# after\nif output.strip():\n    store.append_evidence(session_id, goal_id, EvidenceRecord(text=output.strip()))","handlingStrategy":"validation","validationCode":"text = (evidence_text or '').strip()\nif not text:\n    # skip logging instead of raising downstream\n    logging.debug('skipping empty evidence')\nelse:\n    store.append_evidence(session_id, goal_id, EvidenceRecord(text=text))","typeGuard":"def is_valid_evidence(text: str) -> bool:\n    return isinstance(text, str) and bool(text.strip())","tryCatchPattern":"try:\n    store.append_evidence(session_id, goal_id, ev)\nexcept ValueError as e:\n    if 'cannot be empty' in str(e):\n        pass  # intentionally skip blank evidence\n    else:\n        raise","preventionTips":["Strip-and-check evidence text in agent loops before recording","Skip (don't record) empty tool outputs","Use a descriptive placeholder like '(no output)' when output is legitimately empty"],"tags":["validation","goal-store","evidence","empty-string"],"backgroundTag":"required-field-empty","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}