{"record":{"id":"3d0a50c75157f903","repo":"apache/beam","slug":"micros-implies-microsecond-precision-6-but-precision-was-d","errorCode":null,"errorMessage":"micros implies microsecond precision (6) but precision was %d; use subseconds instead.","messagePattern":"micros implies microsecond precision \\(6\\) but precision was (.+?); use subseconds instead\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/utils/timestamp.py","lineNumber":105,"sourceCode":"          '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    \"\"\"\n    return self._seconds * _POW_10[precision] + (\n        self._subseconds * _POW_10[precision - self._precision])\n\n  @staticmethod","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/utils/timestamp.py#L87-L123","documentation":"When `micros` is given to Timestamp.__init__, precision must equal Timestamp.MICROS_PRECISION (6), because micros inherently encode microsecond resolution. Any other precision raises this ValueError suggesting you use `subseconds` with the desired precision instead.","triggerScenarios":"Timestamp(micros=100, precision=9) or Timestamp(micros=100, precision=0); code that parameterizes precision but passes micros regardless of it.","commonSituations":"Generic timestamp helpers that thread a precision config value through while using the micros shortcut; migrating code from micros to nanosecond precision without switching to subseconds.","solutions":["Use subseconds=micros_value with the desired precision instead of micros","Or drop the precision argument and accept the default microsecond precision (6) when using micros","Set precision=Timestamp.MICROS_PRECISION explicitly if micros must be used"],"exampleFix":"// before\nTimestamp(micros=100, precision=9)\n// after\nTimestamp(subseconds=100, precision=9)","handlingStrategy":"validation","validationCode":"if micros is not None and precision != Timestamp.MICROS_PRECISION:\n    kwargs = dict(subseconds=micros, precision=precision)\nelse:\n    kwargs = dict(micros=micros)","typeGuard":null,"tryCatchPattern":"try:\n    ts = Timestamp(micros=m, precision=p)\nexcept ValueError:\n    ts = Timestamp(subseconds=m, precision=p)","preventionTips":["Use subseconds+precision for any precision other than 6","Never mix the micros shortcut with a configurable precision","Default precision to MICROS_PRECISION when micros is supplied"],"tags":["python","value-error","timestamp","conflicting-args"],"backgroundTag":"conflicting-config-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"}