App throws an error after entering the site URL

App throws an error after entering the site URL

by Sebastian S -
Number of replies: 5

Dear all,

we are currently trying to add mobile support to our Moodle 3.8.5 instance. When given our Moodle's URL (https://moodle.lender.schule), both the mobile and the desktop app fail and throw an error:

Ungültiger Rückgabewert

(which translates to "Invalid return value"). I do not even get to the point where I could insert my credentials.

The FAQ says that this may happen with http-redirects, but
a) I already give an address with https so it should never go to http
b) I can see that the request are not redirected but correctly sent to the https-address (using the debugging tools of the Desktop App) (Apart from that we have HSTS enabled which should prevent any http requests anyway.)
c) I also turned off http forwards and it didn't get better.

The actual server response to token.php is:

  1. {error: "Notwendiger Parameter "username" fehlt", errorcode: "missingparam", stacktrace: null,…}
    1. debuginfo: null
    2. error: "Notwendiger Parameter "username" fehlt"
    3. errorcode: "missingparam"
    4. reproductionlink: null
    5. stacktrace: null
The following call to check.php fails, and the call to service.php?info=tool_mobile_get_public_config results in this:

  1. [{error: true, exception: {message: "Ungültiger Rückgabewert", errorcode: "invalidresponse",…}}]
    1. 0: {error: true, exception: {message: "Ungültiger Rückgabewert", errorcode: "invalidresponse",…}}
      1. error: true
      2. exception: {message: "Ungültiger Rückgabewert", errorcode: "invalidresponse",…}
        1. errorcode: "invalidresponse"
        2. link: "https://moodle.lender.schule/"
        3. message: "Ungültiger Rückgabewert"
        4. moreinfourl: "http://docs.moodle.org/38/de/error/debug/invalidresponse"
The server's error log only outputs this (probably for the first request, though):
[Tue Jun 09 2020] [php7:notice] Default exception handler: Notwendiger Parameter "username" fehlt Debug: \nError code: missingparam\n* line 494 of /lib/setuplib.php: moodle_exception thrown\n* line 562 of /lib/moodlelib.php: call to print_error()\n* line 34 of /login/token.php: call to required_param()\n
Our Moodle runs behind a reverse proxy that also handles the TLS encryption; mobile app access and so on are enabled.
We're running PHP 7.4 with Apache 2.4.38. Latest mobile an desktop apps.
We're using LDAP for authentication (but not with SSO).

What else can I check? Where else should I look?

Thanks
Sebastian

Edit: I recorded the network traffic for this on the server side; it matches what I can see in the developer console. Just to ensure that the reverse proxy doesn't manipulate the data in any unexpected way …
Average of ratings: -
In reply to Sebastian S

Re: App throws an error after entering the site URL

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Sebastian,

if you enable debugging in your site you should be able to see more details about the error. Please go to "Site administration > Development > Debugging", set "Debug messages" to DEVELOPER and try again. Now the exception should include a "debuginfo" property that will tell exactly which field is causing the error.

Cheers,
Dani
Average of ratings: Useful (1)
In reply to Sebastian S

Re: App throws an error after entering the site URL

by Noel De Martin -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Hi there,

The missingparam error from the request to token.php is actually a known issue: MOBILE-3408 and that shouldn't be part of the problem.

As Dani mentioned, if you enable debugging maybe there is something else we can find.

Average of ratings: Useful (1)
In reply to Sebastian S

Re: App throws an error after entering the site URL

by Sebastian S -
Hi Dani and Noel,

thanks for the note about Debugging; I only had it turned up to "all" which didn't give me any additional results but didn't think that "developer" would give me more (silly me). So with that option set I get this when calling service.php:

[{
  "error":true,
  "exception":
  {
    "message":"Ungültiger Rückgabewert",
    "errorcode":"invalidresponse",
    "backtrace":"* line 442 of /lib/externallib.php: invalid_response_exception thrown\n* line 250 of /lib/externallib.php: call to external_api::clean_returnvalue()\n* line 79 of /lib/ajax/service.php: call to external_api::call_external_function()\n",
    "link":"https://moodle.lender.schule/",
    "moreinfourl":"http://docs.moodle.org/38/de/error/debug/invalidresponse",
    "debuginfo": "registerauth => Ungültiger Rückgabewert (Invalid external api response: the value is \"0\" of PHP type \"string\", the server was expecting \"plugin\" type): Invalid external api response: the value is \"0\" of PHP type \"string\", the server was expecting \"plugin\" type\nError code: invalidresponse"
  }
}]
So ... uh ... some misbehaving plugin?
In reply to Sebastian S

Re: App throws an error after entering the site URL

by Dani Palou -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Thanks Sebastian,

can you please search the admin setting named "registerauth"? It's in Site administration > Plugins > Authentication > Manage authentication.

This setting should store the name of the plugin chosen in the database (e.g. "email" for "Email based self-registration"), but for some reason your site has a "0" in there. Moodle cannot find any plugin named "0" so it throws an error.

Cheers,
Dani
Average of ratings: Useful (1)
In reply to Dani Palou

Re: App throws an error after entering the site URL

by Sebastian S -
Hi Dani,

we have self registration disabled, so it's set to 0 in the configuration (our configuration is quite old, though - it was set up with/for Moodle 3.0). I now removed the entry from there and re-set the value through the webfrontend - and indeed, it works!

Big thanks!

But now the login fails with a similiar message:
usercalendartype => Ungültiger Rückgabewert (Invalid external api response: the value is "gregorian " of PHP type "string", the server was expecting "plugin" type): Invalid external api response: the value is "gregorian " of PHP type "string", the server was expecting "plugin" type)

$CFG->calendartype was set to this value, but even after removing that from the config.php, I keep getting this error - do I have to change this in the database? (Also, should I open a new thread for this or is it fine to continue here?)

Edit: Okay, turns out I do have to do so. I updated my users table to remove the stray " " after "gregorian" and now it works like a charm. Thanks a lot for the help!

Thanks
Sebastian