{"record":{"id":"3b2c8ebcdb68b359","repo":"pathwaycom/pathway","slug":"the-max-difference-can-t-be-negative","errorCode":null,"errorMessage":"The 'max_difference' can't be negative","messagePattern":"The 'max_difference' can't be negative","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/_synchronization.py","lineNumber":244,"sourceCode":"    - However, if the second source instead sends a record with ``T + 5m``, this record \\\n      is processed normally. The system will continue waiting for the first source to \\\n      catch up before advancing further.\n\n    This behavior ensures that data gaps do not cause deadlocks but are properly detected and handled.\n    \"\"\"\n\n    if len(columns) < 2:\n        raise ValueError(\"At least two columns must participate in a connector group\")\n\n    if not isinstance(max_difference, int) and not isinstance(\n        max_difference, datetime.timedelta\n    ):\n        raise ValueError(\n            \"The 'max_difference' must either be an integer or a datetime.timedelta\"\n        )\n\n    if isinstance(max_difference, int) and max_difference < 0:\n        raise ValueError(\"The 'max_difference' can't be negative\")\n    if isinstance(\n        max_difference, datetime.timedelta\n    ) and max_difference < datetime.timedelta(0):\n        raise ValueError(\"The 'max_difference' can't be negative\")\n\n    column_types = set()\n    for synchronized_column in columns:\n        if isinstance(synchronized_column, ColumnReference):\n            column = synchronized_column\n            priority = SynchronizedColumn.__dataclass_fields__[\"priority\"].default\n            idle_duration = None\n        else:\n            column = synchronized_column.column\n            priority = synchronized_column.priority\n            idle_duration = synchronized_column.idle_duration\n            if idle_duration is not None:\n                idle_duration = datetime.timedelta(\n                    seconds=as_duration_seconds(idle_duration, \"idle_duration\")","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/_synchronization.py#L226-L262","documentation":"ValueError raised when max_difference is an int but negative. max_difference bounds the tolerated time skew between synchronized sources, so negative values are meaningless.","triggerScenarios":"sync(a.time, b.time, max_difference=-600); a computed int that underflows to negative; negated config value.","commonSituations":"Sign error in configuration; arithmetic on config (e.g. -window for reversed semantics); bad default in shared config.","solutions":["Use a non-negative int (0 is allowed): max_difference=600","Validate config values before building the pipeline: if md < 0: raise ...","If 0 was intended to mean 'no skew tolerance', confirm that is the desired behavior"],"exampleFix":"// before\npw.io.synchronize(a.time, b.time, max_difference=-600)\n\n// after\npw.io.synchronize(a.time, b.time, max_difference=600)","handlingStrategy":"validation","validationCode":"def validate_max_difference(v) -> None:\n    if isinstance(v, int) and not isinstance(v, bool) and v < 0:\n        raise ValueError('max_difference (int seconds) cannot be negative')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check for negative config values before building pipelines","Review sign conventions when reusing window/skew constants","Add schema validation (pydantic, ge=0) for pipeline config"],"tags":["pathway","io","synchronization","validation"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}