In some setup the session seems to not be available. I suspect there might be a regression in XWiki 17.x.
Need to reproduce and debug to find the root cause.