Cron jobs hangs at 10% forever - spams log with [ENOTAUTHENTICATED]

Everything was running fine running 25.04.0 until I updated to 25.04.2.1.

I don’t know what the update changed, but the task had the “admin” user running it, using the “root” makes it work again.
But I didn’t realize until two weeks after and it created a log, 89MB in size, of it spamming:

[ENOTAUTHENTICATED] Not authenticated
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/middlewared/api/base/server/ws_handler/rpc.py", line 323, in process_method_call
    result = await method.call(app, params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/middlewared/api/base/server/method.py", line 47, in call
    await self.middleware.authorize_method_call(app, self.name, methodobj, params)
  File "/usr/lib/python3/dist-packages/middlewared/main.py", line 866, in authorize_method_call
    raise CallError('Not authenticated', ErrnoMixin.ENOTAUTHENTICATED)
middlewared.service_exception.CallError: [ENOTAUTHENTICATED] Not authenticated

This really confuses me. Especially since the cron job never failed, despite this seeming like a critical error.

I realized that this is kind of my weak link, that nothing is actually monitoring if the replication actually happened. And I couldn’t see anything in the alert settings or replication settings that makes you e.g. send a warning or notification alert if the latest replication happened after X time. Is there a way to do custom alert like this?

The script still doesn’t fully run since it now has a bad math expression: operand expected at end of string error, but seems easier to figure out eventually. :sweat_smile:
[Edit - I know why now - since I have SSH access in there that only works with the admin user. :face_with_peeking_eye:]
[Edit2 - I completely forgot that my script depended on running as admin to use the inbuilt SSH keys.]

I tried around more and it doesn’t seem to matter where my script file is placed, as long as I want to run it as my admin user.

It only works with root, but then I can’t use the inbuilt ssh key functionality sadly.

I think I found the source of my issues now: The admin user doesn’t seem to be able to call either midclt call replication.query or midclt call replication.run which than crashes and hangs up the script.
Neither have enough permission to be run by the admin user in cron now. When
I run my script in the normal ZSH shell, it works as expected.

Is this on purpose that the admin user lost this permission somewhere between 25.04.0 and 25.04.2.1?

Also, I noticed that a failed cron job always wants to send an email, even though no mail client is configured / they are disabled instead of raising an alert.