Multiple/Recursive locks are not allowed error (IMediaService.Save)
l

Luuk Peters (Proud Nerds)

6 months ago
Ah yes, Umbraco scoping... I need some help with this one. I simply do not know how to fix this and it's just all trial and error. I think the issue is that there are too many action performed on the database, but what I'm doing doesn't seem so special or difficult. This is Umbracoi 13(.5.2) by the way. First in short the main flow before I give some code: In multiple packages, the following happens: - Package B (Umbraco NuGet package) contains a webhook and receives a post with some data (JSON) - Package B passes the data to Package A (non-Umbraco package) to handle and A create a nice deserialized model of it and invokes an event. - Package B (Umbraco package) listens to the event and when it fires, Package B creates a Media node in Umbraco and puts a file and some meta data in there. - Package B also has a custom Umbraco notification it fires, so that consumers of the package can do some custom action if required. These steps al seem to work all the time. Now in an Umbraco instance, the following happens: - Umbraco handles the custom notification that contains a reference to the media item - Umbraco updates a few fields on the media item and then saves it. This is the step that goes sometimes wrong. Possible issues might be that there are more than 1000 webhook posts done too fast. It could also be a combination of async an non-async stuff. Or I shouldn't give a reference to the media node itself in the notification perhaps. Any ideas? I'll create another post with some minimal and simplified code.
[Solved] Api controller backoffice user is null when firing requests though swagger.
j

Jack

11 months ago
Hello this is my first post. I am trying v14 of Umbraco, and have been following the tutorial on how to add a custom swagger document. Article: https://docs.umbraco.com/umbraco-cms/tutorials/creating-a-backoffice-api/adding-a-custom-swagger-document I created my first simple api controller "logout" and so far so good it shows up on the swagger dashboard. I authorize myself and try requesting from swagger, at first i get a 401, which i don't understand, as i am logged in as an admin.
csharp
namespace Test.Web.Controllers.Api
{
    [ApiController]
    [ApiVersion("1.0")]
    [MapToApi("test-v1")]
    [Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
    [JsonOptionsName(Constants.JsonOptionsNames.BackOffice)]
    [Route("api/v{version:apiVersion}/test")]
    public class LogoutController : Controller
    {
        private readonly INotificationService _notificationService;
        private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
        private readonly IHttpContextAccessor _httpContextAccessor;

        public LogoutController(IBackOfficeSecurityAccessor backOfficeSecurityAccessor, INotificationService notificationService, IHttpContextAccessor httpContextAccessor)
        {
            _backOfficeSecurityAccessor = backOfficeSecurityAccessor;
            _notificationService = notificationService;
            _httpContextAccessor = httpContextAccessor;
        }

        [HttpPost("logout")]
        [MapToApiVersion("1.0")]
        [ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
        public IActionResult Logout()
        {
            IUser? user = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser;
            if (user == null)
            {
                return Unauthorized();
            }

            return Ok();
        }
    }
}
The policy [Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)] Does not seem to be related/assigned to my role, what am i missing ?