{"record":{"id":"f59bb1e6c289d47d","repo":"AvaloniaUI/Avalonia","slug":"invalid-priority-priority","errorCode":null,"errorMessage":"Invalid priority ${priority}","messagePattern":"Invalid priority (.+?)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/AvaloniaObject.cs","lineNumber":894,"sourceCode":"\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        private static void ValidatePriority(BindingPriority priority)\n        {\n            if (priority < BindingPriority.Animation || priority >= BindingPriority.Inherited)\n                ThrowInvalidPriority(priority);\n        }\n\n        private static void ThrowIfReadOnly(AvaloniaProperty property)\n        {\n            if (property.IsReadOnly)\n            {\n                throw new ArgumentException($\"The property {property.Name} is readonly.\");\n            }\n        }\n\n        private static void ThrowInvalidPriority(BindingPriority priority)\n        {\n            throw new ArgumentException($\"Invalid priority ${priority}\", nameof(priority));\n        }\n    }\n}\n","sourceCodeStart":876,"sourceCodeEnd":898,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/AvaloniaObject.cs#L876-L898","documentation":"Thrown by ThrowInvalidPriority when a binding priority is outside the valid range [BindingPriority.Animation, BindingPriority.Inherited). Note: the message contains a literal '${priority}' due to an interpolation bug in the source ($ followed by {priority} instead of {priority}), so the actual priority value is NOT shown in the exception text. Priority must fall within the defined BindingPriority enum band.","triggerScenarios":"Calling SetValue/Bind with a BindingPriority value outside the allowed band; casting an arbitrary int to BindingPriority and passing it.","commonSituations":"Custom binding code that hand-picks a priority; passing default(BindingPriority) in a path that expects a concrete level; numeric coercion bugs.","solutions":["Use one of the named BindingPriority values (Animation, LocalValue, StyleTrigger, etc.) rather than raw ints.","Validate priority with the same bounds check (>= Animation && < Inherited) before calling.","If you see literal '${priority}' in the message, note it is a known formatting defect; inspect the priority argument in a debugger."],"exampleFix":"// before\nobj.SetValue(MyProp, value, (BindingPriority)999);\n\n// after\nobj.SetValue(MyProp, value, BindingPriority.LocalValue);","handlingStrategy":"validation","validationCode":"static bool IsValidPriority(BindingPriority p) =>\n    p >= BindingPriority.Animation && p < BindingPriority.Inherited;","typeGuard":null,"tryCatchPattern":"try { obj.SetValue(prop, value, priority); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Invalid priority\"))\n{ obj.SetValue(prop, value, BindingPriority.LocalValue); }","preventionTips":["Use named BindingPriority values, not raw ints.","Validate the band before calling; remember the message has a formatting bug."],"tags":["property-system","binding","priority","argument","bug-in-message"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}