{"record":{"id":"dcd3b1ffed567e88","repo":"tensorflow/models","slug":"invalid-function-key-for-the-module-s-with-key","errorCode":null,"errorMessage":"Invalid function key for the module: %s with key %s. Valid keys are: %s","messagePattern":"Invalid function key for the module: (.+?) with key (.+?)\\. Valid keys are: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/serving/serving_modules.py","lineNumber":162,"sourceCode":"\n  @tf.function\n  def serve_text_examples(self, inputs) -> Dict[str, tf.Tensor]:\n    name_to_features = {}\n    for text_field in self.params.text_fields:\n      name_to_features[text_field] = tf.io.FixedLenFeature([], tf.string)\n    features = tf.io.parse_example(inputs, name_to_features)\n    segments = [features[x] for x in self.params.text_fields]\n    model_inputs = self._text_processor(segments)\n    if self.params.inputs_only:\n      return self.serve(input_word_ids=model_inputs[\"input_word_ids\"])\n    return self.serve(**model_inputs)\n\n  def get_inference_signatures(self, function_keys: Dict[Text, Text]):\n    signatures = {}\n    valid_keys = (\"serve\", \"serve_examples\", \"serve_text_examples\")\n    for func_key, signature_key in function_keys.items():\n      if func_key not in valid_keys:\n        raise ValueError(\"Invalid function key for the module: %s with key %s. \"\n                         \"Valid keys are: %s\" %\n                         (self.__class__, func_key, valid_keys))\n      if func_key == \"serve\":\n        if self.params.inputs_only:\n          signatures[signature_key] = self.serve.get_concrete_function(\n              input_word_ids=tf.TensorSpec(\n                  shape=[None, None], dtype=tf.int32, name=\"input_word_ids\"))\n        else:\n          signatures[signature_key] = self.serve.get_concrete_function(\n              input_word_ids=tf.TensorSpec(\n                  shape=[None, None], dtype=tf.int32, name=\"input_word_ids\"),\n              input_mask=tf.TensorSpec(\n                  shape=[None, None], dtype=tf.int32, name=\"input_mask\"),\n              input_type_ids=tf.TensorSpec(\n                  shape=[None, None], dtype=tf.int32, name=\"input_type_ids\"))\n      if func_key == \"serve_examples\":\n        signatures[signature_key] = self.serve_examples.get_concrete_function(\n            tf.TensorSpec(shape=[None], dtype=tf.string, name=\"examples\"))","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/serving/serving_modules.py#L144-L180","documentation":"Error \"Invalid function key for the module: %s with key %s. Valid keys are: %s\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/serving/serving_modules.py:162 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}