Steps to replicate the issue (include links if applicable):
On a wiki with no mentors available, submit the following API query:
{ "action": "helppanelquestionposter", "format": "json", "body": "Testing question", "source": "mentor-helppanel", "token": "REPLACE WITH THE ACTUAL CSRF TOKEN", "formatversion": "2" }
By "no mentors available", I mean no mentors listed at Special:ManageMentors and no mentor being already assigned to you.
What happens?:
An unhandled exception is thrown. Currently: [{reqId}] {exception_url} Wikimedia\Assert\InvariantException: Invariant failed: MentorQuestionPoster called without a mentor present
What should have happened instead?:
The API call is invalid (it is not possible to submit a question to a mentor when mentorship is not in use). However, it still should not thrown an unhandled exception.
Other information (browser name/version, screenshots, etc.):
Due to the refactoring done in T351234, the error would change from WikiConfigException to a failed assertion. However, the issue remains the same.
This is not as important, as the API is marked as internal, and only GrowthExperiments itself is supposed to call it. However, we still shouldn't fail hard on invalid calls.



