{"record":{"id":"609916d2a06c6887","repo":"apache/superset","slug":"annotation-parameters-are-invalid","errorCode":null,"errorMessage":"Annotation parameters are invalid.","messagePattern":"Annotation parameters are invalid\\.","errorType":"validation","errorClass":"AnnotationInvalidError","httpStatus":422,"severity":"error","filePath":"superset/commands/annotation_layer/annotation/create.py","lineNumber":72,"sourceCode":"\n        # Validate/populate model exists\n        if not layer_id and not isinstance(layer_id, int):\n            raise AnnotationLayerNotFoundError()\n        annotation_layer = AnnotationLayerDAO.find_by_id(layer_id)\n        if not annotation_layer:\n            raise AnnotationLayerNotFoundError()\n        self._properties[\"layer\"] = annotation_layer\n\n        # Validate short descr uniqueness on this layer\n        if not AnnotationDAO.validate_update_uniqueness(layer_id, short_descr):\n            exceptions.append(AnnotationUniquenessValidationError())\n\n        # validate date time sanity\n        if start_dttm and end_dttm and end_dttm < start_dttm:\n            exceptions.append(AnnotationDatesValidationError())\n\n        if exceptions:\n            raise AnnotationInvalidError(exceptions=exceptions)\n","sourceCodeStart":54,"sourceCodeEnd":73,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/annotation_layer/annotation/create.py#L54-L73","documentation":"AnnotationInvalidError (CommandInvalidError, HTTP 422) raised at the end of AnnotationCreateCommand.validate() when the per-field validation list is non-empty. Two checks feed the list: AnnotationUniquenessValidationError (short_descr already used on that layer) and AnnotationDatesValidationError (end_dttm earlier than start_dttm). The raised error carries the list of Marshmallow ValidationErrors in _exceptions so the API can return field-level details.","triggerScenarios":"POST /api/v1/annotation/ with a short_descr that already exists on the target layer; or with end_dttm < start_dttm (e.g. timezone mix-up flipping the order); both problems at once produce two nested exceptions.","commonSituations":"Duplicate 'launch'/'deploy' markers on the same layer; ISO strings with and without timezone offsets parsed into datetimes whose comparison surprises the author; replaying an import script twice creating the second copy.","solutions":["Check uniqueness first: GET /api/v1/annotation/?q=(layer:<id>,short_descr:eq:<value>) and reuse or rename.","Normalize start_dttm/end_dttm to the same timezone (UTC) and assert end >= start before sending.","Read error._exceptions for field-level messages to know which validation failed."],"exampleFix":"# before\n{\"layer\": 1, \"short_descr\": \"launch\", \"start_dttm\": \"2026-03-02T00:00:00Z\", \"end_dttm\": \"2026-03-01T00:00:00Z\"}\n\n# after\n{\"layer\": 1, \"short_descr\": \"launch-2\", \"start_dttm\": \"2026-03-01T00:00:00Z\", \"end_dttm\": \"2026-03-02T00:00:00Z\"}","handlingStrategy":"validation","validationCode":"from datetime import datetime\n\ndef annotation_valid(layer_id: int, short_descr: str, start: datetime, end: datetime) -> bool:\n    unique = AnnotationDAO.validate_update_uniqueness(layer_id, short_descr)\n    dates_ok = not (start and end and end < start)\n    return unique and dates_ok","typeGuard":null,"tryCatchPattern":"try:\n    CreateAnnotationCommand(properties).run()\nexcept AnnotationInvalidError as ex:\n    field_errors = {e.field_name: e.messages for e in ex._exceptions}\n    return {\"errors\": field_errors}, 422","preventionTips":["Always send start_dttm/end_dttm in one timezone (UTC) and assert ordering before submit.","Check short_descr uniqueness on the target layer via the annotation filter API before create.","Make seed scripts idempotent so re-runs never duplicate descriptions."],"tags":["annotation","validation","uniqueness","dates"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}