server icon indicating copy to clipboard operation
server copied to clipboard

fix: refactor request token handling and do not update with invalid result

Open susnux opened this issue 7 months ago • 4 comments

  • Resolves https://github.com/nextcloud/server/issues/40626

Summary

Originally this should have been only a refactoring to migrate the code to Typescript and add some more tests for it. But doing so I discovered some issues within the logic that revealed to cause the linked issue (or to cause at least the frontend part of it).

  1. If the request fails we should NOT update the token (do not emit an event!)
  2. if a invalid token is about to be set do not update it
  3. some issues noticed where we use the wrong types (e.g. local storage only works with strings).

The issue itself if likely to be orginally caused by some server issue (e.g. overloaded) which causes a 500 return, then we have an "undefined" token (as the old code did not check for the validity) and tried to update it. This causes all following requests to use an invalid token.

Checklist

susnux avatar Jun 04 '25 17:06 susnux

Best to review commit by commit - most changes are tests only.

susnux avatar Jun 04 '25 17:06 susnux

/backport to stable31

susnux avatar Jun 04 '25 17:06 susnux

/backport to stable30

susnux avatar Jun 04 '25 17:06 susnux

/compile

susnux avatar Jun 16 '25 13:06 susnux

Thank you for this! The linked bug has been present for years, I really hope this is the end of it.

michnovka avatar Jun 16 '25 15:06 michnovka