luci-base: dispatcher.uc: improve error reporting for actionless nodes
In case a - potentially auto-created, intermediate - node is requested, reply with a clean HTTP 404 error instead of an internal assertion about an unknown action type. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
ec8cf9e83c
commit
86f04d85fc
1 changed files with 11 additions and 6 deletions
|
@ -772,7 +772,7 @@ function render_action(fn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_action(request_path, lang, tree, resolved, action) {
|
function run_action(request_path, lang, tree, resolved, action) {
|
||||||
switch (action?.type) {
|
switch ((type(action) == 'object') ? action.type : 'none') {
|
||||||
case 'template':
|
case 'template':
|
||||||
if (runtime.is_ucode_template(action.path))
|
if (runtime.is_ucode_template(action.path))
|
||||||
runtime.render(action.path, {});
|
runtime.render(action.path, {});
|
||||||
|
@ -840,11 +840,16 @@ function run_action(request_path, lang, tree, resolved, action) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'firstchild':
|
case 'firstchild':
|
||||||
if (!length(tree.children))
|
if (!length(tree.children)) {
|
||||||
error404("No root node was registered, this usually happens if no module was installed.\n" +
|
error404("No root node was registered, this usually happens if no module was installed.\n" +
|
||||||
"Install luci-mod-admin-full and retry. " +
|
"Install luci-mod-admin-full and retry. " +
|
||||||
"If the module is already installed, try removing the /tmp/luci-indexcache file.");
|
"If the module is already installed, try removing the /tmp/luci-indexcache file.");
|
||||||
else
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fall through */
|
||||||
|
|
||||||
|
case 'none':
|
||||||
error404(`No page is registered at '/${entityencode(join("/", resolved.ctx.request_path))}'.\n` +
|
error404(`No page is registered at '/${entityencode(join("/", resolved.ctx.request_path))}'.\n` +
|
||||||
"If this url belongs to an extension, make sure it is properly installed.\n" +
|
"If this url belongs to an extension, make sure it is properly installed.\n" +
|
||||||
"If the extension was recently installed, try removing the /tmp/luci-indexcache file.");
|
"If the extension was recently installed, try removing the /tmp/luci-indexcache file.");
|
||||||
|
|
Loading…
Reference in a new issue