{"record":{"id":"f3647c76608f7780","repo":"elsa-workflows/elsa-core","slug":"bpmn-element-timer-elementid-declares-the-timer-duration","errorCode":null,"errorMessage":"BPMN element '{timer.ElementId}' declares the timer duration '{timer.IsoDuration}', which is not an ISO-8601 duration Elsa can wait for.","messagePattern":"BPMN element '(.+?)' declares the timer duration '(.+?)', which is not an ISO-8601 duration Elsa can wait for\\.","errorType":"exception","errorClass":"BpmnBindingException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Bpmn.Interchange/Binding/BpmnWorkBinder.cs","lineNumber":180,"sourceCode":"    private static void RefuseUnusedDeclarations(BpmnProcessDefinition definition, ISet<string> consumed)\n    {\n        foreach (var element in definition.Elements.Where(element => BpmnActivityBindingFormat.Find(element.Extensions) is not null && !consumed.Contains(element.ElementId)))\n        {\n            throw new BpmnBindingException(\n                $\"BPMN element '{element.ElementId}' ({element.ElementType}) of process '{definition.ProcessId}' carries an <{BpmnActivityBindingFormat.NamespacePrefix}:{BpmnActivityBindingFormat.BindingElementName}> element, but its work is not an unbound task, so nothing would ever run it. \"\n                + \"Only a task the document describes without implementing takes an authored activity binding.\");\n        }\n    }\n\n    private static TimeSpan IsoDurationOf(BpmnWorkBinding.TimerWait timer)\n    {\n        try\n        {\n            return XmlConvert.ToTimeSpan(timer.IsoDuration);\n        }\n        catch (Exception exception) when (exception is FormatException or OverflowException or ArgumentNullException)\n        {\n            throw new BpmnBindingException($\"BPMN element '{timer.ElementId}' declares the timer duration '{timer.IsoDuration}', which is not an ISO-8601 duration Elsa can wait for.\");\n        }\n    }\n\n    private static string CalledElementOf(BpmnWorkBinding.CallProcess call) =>\n        !string.IsNullOrWhiteSpace(call.CalledElement)\n            ? call.CalledElement\n            : throw new BpmnBindingException($\"BPMN element '{call.ElementId}' is a call activity that names no calledElement, so there is no workflow definition to dispatch.\");\n}\n","sourceCodeStart":162,"sourceCodeEnd":189,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Bpmn.Interchange/Binding/BpmnWorkBinder.cs#L162-L189","documentation":"A timer element's duration string must be a valid ISO-8601 duration (e.g. PT5M). This error wraps XmlConvert.ToTimeSpan failing with FormatException, OverflowException, or ArgumentNullException when converting the declared duration to a TimeSpan.","triggerScenarios":"BpmnWorkBinder.IsoDurationOf (called from CreateActivity for a TimerWait binding) calls XmlConvert.ToTimeSpan(timer.IsoDuration) and it throws — the timer's declared duration is null, malformed, or out of range.","commonSituations":"Writing human formats like '5 minutes' or '5m' instead of 'PT5M'; forgetting the required 'PT' prefix; copying timestamps ('2026-01-01T10:00:00Z') into a duration field.","solutions":["Correct the duration to ISO-8601 form: P[nD]T[nH][nM][nS], e.g. PT30S, PT5M, PT1H30M, P1D.","Ensure the prefix is PT for time-only durations (P for days) and units are ordered D, H, M, S.","Validate the string with XmlConvert.ToTimeSpan in a scratch test before re-importing."],"exampleFix":"// before\n<bpmn:intermediateCatchEvent id=\"Wait1\"><bpmn:timerEventDefinition><bpmn:timeDuration>5 minutes</bpmn:timeDuration></bpmn:timerEventDefinition></bpmn:intermediateCatchEvent>\n// after\n<bpmn:intermediateCatchEvent id=\"Wait1\"><bpmn:timerEventDefinition><bpmn:timeDuration>PT5M</bpmn:timeDuration></bpmn:timerEventDefinition></bpmn:intermediateCatchEvent>","handlingStrategy":"validation","validationCode":"try { XmlConvert.ToTimeSpan(durationText); }\ncatch (Exception ex) when (ex is FormatException or OverflowException or ArgumentNullException)\n{ throw new InvalidOperationException($\"'{durationText}' is not an ISO-8601 duration (e.g. PT5M).\"); }","typeGuard":"static bool IsValidIsoDuration(string? s)\n{\n    try { XmlConvert.ToTimeSpan(s); return true; }\n    catch (Exception e) when (e is FormatException or OverflowException or ArgumentNullException) { return false; }\n}","tryCatchPattern":"try { await importer.ImportAsync(bpmn); }\ncatch (BpmnBindingException ex) when (ex.Message.Contains(\"not an ISO-8601 duration\"))\n{\n    logger.LogError(ex, \"Fix the timer duration to ISO-8601 form such as PT5M.\");\n}","preventionTips":["Always write durations in ISO-8601 form with the PT (or P) prefix","Validate <timeDuration> values with XmlConvert.ToTimeSpan before import","Never put dates or human phrases in duration fields"],"tags":["bpmn","timer","iso-8601","duration"],"backgroundTag":"invalid-duration-format","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}