{"record":{"id":"0e4c75b2db5ad78b","repo":"apache/beam","slug":"micros-and-subseconds-are-mutually-exclusive-got-micros-s","errorCode":null,"errorMessage":"micros and subseconds are mutually exclusive, got micros=%s, subseconds=%s.","messagePattern":"micros and subseconds are mutually exclusive, got micros=(.+?), subseconds=(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/utils/timestamp.py","lineNumber":101,"sourceCode":"      raise TypeError(\n          'Cannot interpret %s %s as seconds.' % (seconds, type(seconds)))\n    if not isinstance(subseconds, (int, float)):\n      raise TypeError(\n          'Cannot interpret %s %s as subseconds.' %\n          (subseconds, type(subseconds)))\n    if not isinstance(precision, int):\n      raise TypeError(\n          'Cannot interpret %s %s as precision.' % (precision, type(precision)))\n    if not 0 <= precision <= Timestamp.NANOS_PRECISION:\n      raise ValueError(\n          'Timestamp precision must be between 0 and %d (inclusive), '\n          'but was %d.' % (Timestamp.NANOS_PRECISION, precision))\n    if micros is not None:\n      if not isinstance(micros, (int, float)):\n        raise TypeError(\n            'Cannot interpret %s %s as micros.' % (micros, type(micros)))\n      if subseconds:\n        raise ValueError(\n            'micros and subseconds are mutually exclusive, got micros=%s, '\n            'subseconds=%s.' % (micros, subseconds))\n      if precision != Timestamp.MICROS_PRECISION:\n        raise ValueError(\n            'micros implies microsecond precision (6) but precision was %d; '\n            'use subseconds instead.' % precision)\n      subseconds = micros\n    self._precision = precision\n    total = int(seconds * _POW_10[precision]) + int(subseconds)\n    self._seconds, self._subseconds = divmod(total, _POW_10[precision])\n\n  def _total(self, precision: int) -> int:\n    \"\"\"Returns the total time since the epoch in units of 10**-precision\n    seconds.\n\n    ``precision`` must be greater than or equal to this timestamp's\n    precision, so that scaling up is always lossless.\n    \"\"\"","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/utils/timestamp.py#L83-L119","documentation":"Timestamp.__init__ forbids supplying both `micros` and a truthy `subseconds` because they are two representations of the same quantity and would be ambiguous. Supplying both raises a ValueError telling you which values conflicted.","triggerScenarios":"Timestamp(micros=100, subseconds=50) — micros is not None and subseconds is truthy; passing subseconds=0 with micros is allowed (0 is falsy).","commonSituations":"Refactor that switched from subseconds to micros but left the old argument in place; generic wrapper code that forwards all kwargs; copy-paste in tests.","solutions":["Remove the subseconds argument and keep only micros","Or remove micros and express the value entirely as subseconds","Note subseconds=0 with micros is permitted, so only nonzero subseconds conflict"],"exampleFix":"// before\nTimestamp(micros=100, subseconds=50)\n// after\nTimestamp(micros=100)  # or Timestamp(subseconds=50, precision=...)","handlingStrategy":"validation","validationCode":"if micros is not None and subseconds:\n    raise ValueError('pass either micros or subseconds, not both')","typeGuard":null,"tryCatchPattern":"try:\n    ts = Timestamp(**kwargs)\nexcept ValueError as e:\n    if 'mutually exclusive' in str(e):\n        kwargs.pop('subseconds', None)\n        ts = Timestamp(**kwargs)","preventionTips":["In wrapper functions, pass only one of micros/subseconds based on a flag","Audit kwargs-forwarding call sites when adding new constructor params","Prefer the subseconds+precision form as the single canonical path"],"tags":["python","value-error","timestamp","conflicting-args"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}