Shortcuts Saving a file generates error - NSFileProviderErrorDomain, -1005)

I had a shortcuts routine that appended data to a CSV file which suddenly threw the following error on the save or append command when I updated to iOS15:

View the shortcut for more details.
(NSFileProviderErrorDomain,
-1005)

As it took me 2 hours to work out how to fix, I thought I would post for anyone trying to solve the same issue.

Solution : in Shortcuts go into the details / settings for the specific routine (the button that looks like 3 horizontal sliders). Press the “Privacy” Tab. Press “Reset Privacy”
The next time the routine runs it will ask for new permissions but then has run correctly since.

Hope this helps others.