CXuesong / WikiClientLibrary

/*🌻*/ Wiki Client Library is an asynchronous MediaWiki API client library targeting modern .NET platforms
https://github.com/CXuesong/WikiClientLibrary/wiki
Apache License 2.0
80 stars 16 forks source link

Strange error message #48

Closed HarelM closed 5 years ago

HarelM commented 5 years ago

I'm getting the following error message:

> (Inner Exception #4) System.AggregateException: One or more errors occurred. (assertuserfailed:Assertion that the user is logged in failed.) ---> WikiClientLibrary.AccountAssertionFailureException: assertuserfailed:Assertion that the user is logged in failed.
   at WikiClientLibrary.Client.MediaWikiJsonResponseParser.OnApiError(String errorCode, String errorMessage, JToken errorNode, JToken responseNode, WikiResponseParsingContext context)
   at WikiClientLibrary.Client.MediaWikiJsonResponseParser.<ParseResponseAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---

I'm not sure why I got this error message but restarting the process solved it. Is there an expiration to user credentials? Should I be expecting this exception and heal from it somehow? Any help would be appreciated! :-)

CXuesong commented 5 years ago

Yes, your login information has expired.

WCL enables account assertion by default; that is, if you have logged in as a user or a bot, WikiSite will automatically append assert=user or assert=bot to all of your MW API request, just in case your session got lost or expired from a certain point of time. For example, if your session got expired when you were making a batch edit, an AccountAssertionFailureException will be thrown to prevent you from further editing, instead of letting you continue editing, usually unknowningly, as an anonymous user.

You can control this behavior with SiteOptions.AccountAssertion. If you want to login back and automatically retry the last request whenever your login information gets lost or expired, consider setting WikiSite.AccountAssertionFailureHandler.

HarelM commented 5 years ago

Thanks for the quick response! I think you can close this issue, unless you would like to document this somewhere for future reference.