{"record":{"id":"93acb8e0ffecb8f4","repo":"keras-team/keras","slug":"invalid-curve-argument-value-curve-expected","errorCode":null,"errorMessage":"Invalid `curve` argument value \"{curve}\". Expected one of: {list(metrics_utils.AUCCurve)}","messagePattern":"Invalid `curve` argument value \"(.+?)\"\\. Expected one of: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/metrics/confusion_metrics.py","lineNumber":1209,"sourceCode":"        num_thresholds=200,\n        curve=\"ROC\",\n        summation_method=\"interpolation\",\n        name=None,\n        dtype=None,\n        thresholds=None,\n        multi_label=False,\n        num_labels=None,\n        label_weights=None,\n        from_logits=False,\n    ):\n        # Metric should be maximized during optimization.\n        self._direction = \"up\"\n\n        # Validate configurations.\n        if isinstance(curve, metrics_utils.AUCCurve) and curve not in list(\n            metrics_utils.AUCCurve\n        ):\n            raise ValueError(\n                f'Invalid `curve` argument value \"{curve}\". '\n                f\"Expected one of: {list(metrics_utils.AUCCurve)}\"\n            )\n        if isinstance(\n            summation_method, metrics_utils.AUCSummationMethod\n        ) and summation_method not in list(metrics_utils.AUCSummationMethod):\n            raise ValueError(\n                \"Invalid `summation_method` \"\n                f'argument value \"{summation_method}\". '\n                f\"Expected one of: {list(metrics_utils.AUCSummationMethod)}\"\n            )\n\n        # Update properties.\n        self._init_from_thresholds = thresholds is not None\n        if thresholds is not None:\n            # If specified, use the supplied thresholds.\n            self.num_thresholds = len(thresholds) + 2\n            thresholds = sorted(thresholds)","sourceCodeStart":1191,"sourceCodeEnd":1227,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/metrics/confusion_metrics.py#L1191-L1227","documentation":"Raised by keras.metrics.AUC's __init__ when curve is an AUCCurve enum instance that is not a supported member (ROC or PR). This fires only when you pass an enum instance; plain strings are handled by a different code path.","triggerScenarios":"Passing a stale or custom AUCCurve enum member (e.g. pickled from an older TF/Keras version, or a dynamically constructed enum) to keras.metrics.AUC(curve=...).","commonSituations":"Code migrated from tensorflow.keras that persisted enum objects across versions; monkeypatched or dynamically created enum members.","solutions":["Pass a string instead: curve='ROC' or curve='PR'.","If enums are needed, import AUCCurve from the same Keras version's metrics_utils.","Regenerate pickled/saved configs containing enum objects."],"exampleFix":"# before\nfrom keras.src.metrics import metrics_utils\nauc = keras.metrics.AUC(curve=metrics_utils.AUCCurve('SQ'))\n\n# after\nauc = keras.metrics.AUC(curve='PR')","handlingStrategy":"validation","validationCode":"assert curve in ('ROC', 'PR'), f'curve must be ROC or PR, got {curve}'","typeGuard":"def is_valid_curve(v) -> bool:\n    return v in ('ROC', 'PR')","tryCatchPattern":null,"preventionTips":["Pass strings, not enums, for serialization-friendly configs.","Never pickle enum objects across version upgrades."],"tags":["keras","metrics","auc","enum-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}