{"record":{"id":"a66dd5802f3f8cc3","repo":"apache/beam","slug":"s-hint-s-type-constraint-violated-all-s-should-be-of-type-s","errorCode":null,"errorMessage":"%s hint %s-type constraint violated. All %s should be of type %s. Instead: %s","messagePattern":"(.+?) hint (.+?)-type constraint violated\\. All (.+?) should be of type (.+?)\\. Instead: (.+?)","errorType":"exception","errorClass":"CompositeTypeHintError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/typehints/typehints.py","lineNumber":888,"sourceCode":"    def __hash__(self):\n      return hash((type(self), self.key_type, self.value_type))\n\n    def _inner_types(self):\n      yield self.key_type\n      yield self.value_type\n\n    def _consistent_with_check_(self, sub):\n      return (\n          isinstance(sub, self.__class__) and\n          is_consistent_with(sub.key_type, self.key_type) and\n          is_consistent_with(sub.value_type, self.value_type))\n\n    def _raise_hint_exception_or_inner_exception(\n        self, is_key, incorrect_instance, inner_error_message=''):\n      incorrect_type = 'values' if not is_key else 'keys'\n      hinted_type = self.value_type if not is_key else self.key_type\n      if inner_error_message:\n        raise CompositeTypeHintError(\n            '%s hint %s-type constraint violated. All %s should be of type '\n            '%s. Instead: %s' % (\n                repr(self),\n                incorrect_type[:-1],\n                incorrect_type,\n                repr(hinted_type),\n                inner_error_message))\n      else:\n        raise CompositeTypeHintError(\n            '%s hint %s-type constraint violated. All %s should be of '\n            'type %s. Instead, %s is of type %s.' % (\n                repr(self),\n                incorrect_type[:-1],\n                incorrect_type,\n                repr(hinted_type),\n                incorrect_instance,\n                incorrect_instance.__class__.__name__))\n","sourceCodeStart":870,"sourceCodeEnd":906,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/typehints/typehints.py#L870-L906","documentation":"Runtime type-check failure for a KV[K, V] constraint: one of the keys or values inside a provided tuple does not match its hinted type (the message says whether it is the key or value slot and shows the offending element). It is raised from type_check during pipeline execution when the hint's inner check fails.","triggerScenarios":"A key or value that must satisfy a composite hint (Tuple/List/Dict/Union) fails, e.g. Dict[str, Tuple[int, int]] receiving {'a': (1,)}; type_check catches CompositeTypeHintError and re-raises via this helper.","commonSituations":"Values built as nested structures whose inner shape drifted; keys built as tuples/Unions with wrong content.","solutions":["Read the embedded inner message for the deepest failing constraint","Fix the offending key/value to satisfy the composite hint","Update the hint if the nested structure legitimately changed"],"exampleFix":"# before\nDict[str, Tuple[int, int]]: {'a': (1,)}\n# after\n{'a': (1, 2)}","handlingStrategy":"validation","validationCode":"for k, v in d.items():\n    if not (isinstance(v, tuple) and len(v) == 2): raise ValueError(f'value for {k!r} violates nested hint: {v!r}')","typeGuard":"def conforms(d, kcheck, vcheck): return isinstance(d, dict) and all(kcheck(k) and vcheck(v) for k, v in d.items())","tryCatchPattern":null,"preventionTips":["Validate dict values at ingestion","Keep nested hints synced with data-model changes"],"tags":["python","apache-beam","type-hints","dict"],"backgroundTag":"type-mismatch","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"}