{"record":{"id":"9884684ebf068287","repo":"jenkinsci/jenkins","slug":"view-getviewname-view-can-not-contain-views","errorCode":null,"errorMessage":"{view.getViewName()} view can not contain views","messagePattern":"(.+?) view can not contain views","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java","lineNumber":114,"sourceCode":"\n        final StringTokenizer tok = new StringTokenizer(name, \"/\");\n        while (tok.hasMoreTokens()) {\n\n            String viewName = tok.nextToken();\n\n            view = group.getView(viewName);\n            if (view == null) {\n                group.checkPermission(View.READ);\n                throw new IllegalArgumentException(String.format(\n                        \"No view named %s inside view %s\",\n                        viewName, group.getDisplayName()\n                ));\n            }\n            view.checkPermission(View.READ);\n            if (view instanceof ViewGroup) {\n                group = (ViewGroup) view;\n            } else if (tok.hasMoreTokens()) {\n                throw new IllegalStateException(view.getViewName() + \" view can not contain views\");\n            }\n        }\n\n        return view;\n    }\n\n    @Override\n    public String getDefaultMetaVariable() {\n\n        return \"VIEW\";\n    }\n}\n","sourceCodeStart":96,"sourceCodeEnd":127,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java#L96-L127","documentation":"IllegalStateException from ViewOptionHandler when the path still has tokens but the current view is not a ViewGroup (it cannot contain child views). The check is `else if (tok.hasMoreTokens())` after the `view instanceof ViewGroup` branch.","triggerScenarios":"A view path like `-v a/b/c` where `a` (or `a/b`) resolves to a leaf view that does not implement ViewGroup.","commonSituations":"Treating a flat/leaf view as if it were nested; plugin view type that aggregates but is not a ViewGroup.","solutions":["Pass only the leaf view's own name (drop the extra path segments).","Confirm the parent segment is actually a ViewGroup before nesting.","Use a view type that implements ViewGroup if nesting is required."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if (!(view instanceof ViewGroup) && tok.hasMoreTokens()) {\n    throw new IllegalStateException(view.getViewName() + \" cannot contain views\");\n}","typeGuard":"boolean canNest(View v) { return v instanceof ViewGroup; }","tryCatchPattern":"catch (IllegalStateException e) { /* leaf view used as a path parent */ }","preventionTips":["Only nest through ViewGroup-implementing views.","Address leaf views by their own name."],"tags":["cli","view","type-mismatch"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}