{"record":{"id":"9d28aeaa560933f8","repo":"HKUDS/Vibe-Trading","slug":"start-lower-is-after-end-upper","errorCode":null,"errorMessage":"start {lower} is after end {upper}","messagePattern":"start (.+?) is after end (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/cashflow.py","lineNumber":395,"sourceCode":"        \"\"\"Select flows within an inclusive date window.\n\n        Args:\n            start: Earliest date to keep, inclusive. ``None`` leaves the window\n                open on the left.\n            end: Latest date to keep, inclusive. ``None`` leaves it open on the\n                right.\n\n        Returns:\n            A new ``CashFlowSeries`` holding only flows inside the window.\n\n        Raises:\n            ValueError: If a bound is not a supported date value, or if\n                ``start`` is later than ``end``.\n        \"\"\"\n        lower = normalize_date(start, field_name=\"start\") if start is not None else None\n        upper = normalize_date(end, field_name=\"end\") if end is not None else None\n        if lower is not None and upper is not None and lower > upper:\n            raise ValueError(f\"start {lower} is after end {upper}\")\n        return self._rebuild(\n            flow\n            for flow in self.flows\n            if (lower is None or flow.date >= lower)\n            and (upper is None or flow.date <= upper)\n        )\n\n    def total(self, *, include_valuations: bool = False) -> float:\n        \"\"\"Sum the signed amounts.\n\n        Valuation marks such as NAV are excluded by default: adding a mark to\n        settled cash would overstate what was actually received.\n\n        Args:\n            include_valuations: Set True to include ``VALUATION_KINDS`` records,\n                as required when computing a fund's IRR against terminal NAV.\n\n        Returns:","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/cashflow.py#L377-L413","documentation":"CashFlowSeries.between(start, end) normalizes both date bounds and requires start <= end; a reversed window is rejected instead of silently returning an empty slice, which would look like 'no flows in period' and mislead analysis.","triggerScenarios":"series.between('2024-12-31', '2024-01-01') or passing date bounds in the wrong order from swapped variables.","commonSituations":"Arguments transposed at the call site; a UI reporting period where the user picked the end date first; variables named from/to accidentally swapped.","solutions":["Swap the arguments so start is the earlier bound","If bounds come from user input, sort them: start, end = min(a,b), max(a,b) when order is irrelevant, or validate and surface a clear message"],"exampleFix":"# before\nseries.between(end='2024-12-31', start='2024-01-01')\n# after\nseries.between(start='2024-01-01', end='2024-12-31')","handlingStrategy":"validation","validationCode":"start, end = min(start, end), max(start, end)  # if order is user-supplied\nseries.between(start, end)","typeGuard":null,"tryCatchPattern":"try:\n    window = series.between(start, end)\nexcept ValueError as e:\n    if 'is after' in str(e):\n        window = series.between(end, start)","preventionTips":["Validate period inputs in the UI/API layer before calling between","Use keyword arguments start=/end= to avoid positional swaps"],"tags":["python","cashflow","date-range","validation"],"backgroundTag":"invalid-date-range","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}