Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-5436

Add capability to turn off include error message and make note of this in Conf user guide/admin guide docs

    • 6
    • 3
    • We collect Confluence feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      NOTE: This suggestion is for Confluence Server. Using Confluence Cloud? See the corresponding suggestion.

      A customer was complaining about the error message that appears in Confluence if the user does not have permissions to view the content included via an include. As such:

      1. Can we please add a flag to the include macro so that the error message can be turned off so that the page will render seamlessly (with no error messages) regardless of the include existing and the viewers permissions.

      Alternative Simple Solution

      1. Can Confluence can handle this warning with a more friendly message (e.g. You do not have permission to view this page.)

      We also need to make note of this in the Confluence documentation - in the user guide I'd suggest.

          Form Name

            [CONFSERVER-5436] Add capability to turn off include error message and make note of this in Conf user guide/admin guide docs

            Hi, 

            we have the same problem for the Include Page macro. So I tried the user macro by Arjen. Unfortunately it didn't work so I wrote the following one: 

            ## Macro title: Include Restricted Page
            ##
            ## Developed by: My Name
            ## Date created: dd/mm/yyyy
            ## Installed by: My Name
            
            ## @param Link:title=Internal Link|type=confluence-content|required=true|desc=Choose the local destination page. 
            
            #set ($colonIndex = $paramLink.indexOf(":"))
            #if ($colonIndex == -1)
              #set ($spaceKey = $space.key)
              #set ($pageName = $paramLink)
            #else
              #set ($spaceKey = $paramLink.substring(0, $colonIndex))
              #set ($pageNameIndex = $colonIndex + 1 )
              #set ($pageName = $paramLink.substring($pageNameIndex))
            #end
            #set ($page = $pageManager.getPage($spaceKey, $pageName))#set($m1 = "{include:")
            #set ($m2 = "}")
            #set ($macro = "${m1}${spaceKey}:${pageName}${m2}")#if ($permissionHelper.canViewPage($action.remoteUser, $spaceKey, $pageName) == true)
              $action.getHelper().renderConfluenceMacro($macro)
            #else
              <span>Page not found!</span>
            #end
            

            Regards
            Fabian

            Fabian Hußl added a comment - Hi,  we have the same problem for the Include Page macro. So I tried the user macro by Arjen. Unfortunately it didn't work so I wrote the following one:  ## Macro title: Include Restricted Page ## ## Developed by: My Name ## Date created: dd/mm/yyyy ## Installed by: My Name ## @param Link:title=Internal Link|type=confluence-content|required= true |desc=Choose the local destination page. #set ($colonIndex = $paramLink.indexOf( ":" )) # if ($colonIndex == -1) #set ($spaceKey = $space.key) #set ($pageName = $paramLink) # else #set ($spaceKey = $paramLink.substring(0, $colonIndex)) #set ($pageNameIndex = $colonIndex + 1 ) #set ($pageName = $paramLink.substring($pageNameIndex)) #end #set ($page = $pageManager.getPage($spaceKey, $pageName))#set($m1 = "{include:" ) #set ($m2 = "}" ) #set ($macro = "${m1}${spaceKey}:${pageName}${m2}" )# if ($permissionHelper.canViewPage($action.remoteUser, $spaceKey, $pageName) == true ) $action.getHelper().renderConfluenceMacro($macro) # else <span>Page not found!</span> #end Regards Fabian

            I took the macro code of @DaveT and altered it to work for the Include Page macro instead of the Include Excerpt. Thanks for your code @DaveT.

             

            ## Macro title: Include Restricted Page
            ## Date created: 01/11/2018
            ## Macro has a body: N
            ## @param space:title=Space|type=spacekey|desc=Space where the page excerpt is found
            ## @param page:title=Page|type=confluence-content|required=true|desc=Page where the excerpt is found
            ## Check for valid space key, otherwise use current
            #set($spacekey= $paramspace)
            #if (!$spacekey)
             #set ($spacekey=$space.key)
            #end
            #set($m1 = "{include:")
            #set($m2 = "}")
            #set($macro = "${m1}${spacekey}:${parampage}${m2}")
            #if ($permissionHelper.canViewPage($action.remoteUser, $spacekey, $parampage))
             $action.getHelper().renderConfluenceMacro($macro)
            #end
            

             

            Arjen Breur added a comment - I took the macro code of @DaveT and altered it to work for the Include Page macro instead of the Include Excerpt . Thanks for your code @DaveT.   ## Macro title: Include Restricted Page ## Date created: 01/11/2018 ## Macro has a body: N ## @param space:title=Space|type=spacekey|desc=Space where the page excerpt is found ## @param page:title=Page|type=confluence-content|required= true |desc=Page where the excerpt is found ## Check for valid space key, otherwise use current #set($spacekey= $paramspace) # if (!$spacekey) #set ($spacekey=$space.key) #end #set($m1 = "{include:" ) #set($m2 = "}" ) #set($macro = "${m1}${spacekey}:${parampage}${m2}" ) # if ($permissionHelper.canViewPage($action.remoteUser, $spacekey, $parampage)) $action.getHelper().renderConfluenceMacro($macro) #end  

            Tim added a comment -

            Imho is the issuetype Suggestion wrong, it is a bug. There should be no error thrown and no stacktrace (which btw spams the logfile and cannot be easily suppressed unless dropping all errors for the package xhtml.view.macro.ViewMacroMarshaller), as a configuration with an unrestricted page, including a restricted page is perfectly valid. It is simply no error.

            This should be handled silently by confluence without any stacktrace in the log nor any error message on the page itself. The behaviour should be consistent with other permission handling, where users without permissions don't see pages in search results, structured views like children pages, or recent edits at all, being kept unaware of their existence.

            Tim added a comment - Imho is the issuetype Suggestion wrong, it is a bug. There should be no error thrown and no stacktrace (which btw spams the logfile and cannot be easily suppressed unless dropping all errors for the package xhtml.view.macro.ViewMacroMarshaller), as a configuration with an unrestricted page, including a restricted page is perfectly valid. It is simply no error. This should be handled silently by confluence without any stacktrace in the log nor any error message on the page itself. The behaviour should be consistent with other permission handling, where users without permissions don't see pages in search results, structured views like children pages, or recent edits at all, being kept unaware of their existence.

            DaveT added a comment -

            I was able to work around my problem by creating a user macro:

            ## Macro title: My Macro
            ## Macro has a body: Y or N
            ## Body processing: Selected body processing option
            ## Output: Selected output option
            ##
            ## Developed by: My Name
            ## Date created: dd/mm/yyyy
            ## Installed by: My Name
            
            ## This is an example macro
            ## @param space:title=Space|type=spacekey|desc=Space where the page excerpt is found
            ## @param page:title=Page|type=confluence-content|required=true|desc=Page where the excerpt is found
            ## Check for valid space key, otherwise use current
            #set($spacekey= $paramspace)
            #if (!$spacekey)
              #set ($spacekey=$space.key)
            #end
            #set($m1 = "{excerpt-include:")
            #set($m2 = "}")
            #set($macro = "${m1}$parampage|nopanel=true${m2}")
            
            #if ($permissionHelper.canViewPage($action.remoteUser, $spacekey, $parampage))
              $action.getHelper().renderConfluenceMacro($macro)
            #end
            

            DaveT added a comment - I was able to work around my problem by creating a user macro: ## Macro title: My Macro ## Macro has a body: Y or N ## Body processing: Selected body processing option ## Output: Selected output option ## ## Developed by: My Name ## Date created: dd/mm/yyyy ## Installed by: My Name ## This is an example macro ## @param space:title=Space|type=spacekey|desc=Space where the page excerpt is found ## @param page:title=Page|type=confluence-content|required=true|desc=Page where the excerpt is found ## Check for valid space key, otherwise use current #set($spacekey= $paramspace) #if (!$spacekey) #set ($spacekey=$space.key) #end #set($m1 = "{excerpt-include:") #set($m2 = "}") #set($macro = "${m1}$parampage|nopanel=true${m2}") #if ($permissionHelper.canViewPage($action.remoteUser, $spacekey, $parampage)) $action.getHelper().renderConfluenceMacro($macro) #end

            DaveT added a comment -

            My use case is a bit different in that it's the excerpt-include macro that's generating the error. If the user doesn't have access to the page where the excerpt source resides, the macro generates <p>The page xxxxxx does not exist.</p> There's no surrounding div or span and there's no class or other distinguishing markup that I can look for to eliminate this.

            Given the age and lack of votes on this issue, I'm pessimistic that it will be addressed. As a result, I'm going to try to find another macro that will allow me to check the user's permissions before attempting to render the content.

            DaveT added a comment - My use case is a bit different in that it's the excerpt-include macro that's generating the error. If the user doesn't have access to the page where the excerpt source resides, the macro generates <p>The page xxxxxx does not exist.</p> There's no surrounding div or span and there's no class or other distinguishing markup that I can look for to eliminate this. Given the age and lack of votes on this issue, I'm pessimistic that it will be addressed. As a result, I'm going to try to find another macro that will allow me to check the user's permissions before attempting to render the content.

            The solution I have found best for myself is to use jQuery to remove the element all together. I am running v5.5.2, of which the error message element does not have a class (.error) therefore I cannot use the solution mentioned by Zacharie Eakin. Keep in mind this may not be best for all releases of Confluence.

            <script>
            $('span:contains("Unable to render {include}")').parent().remove();
            </script>
            

            I've only implemented this on a per page basis (as needed) using the HTML macro as I don't believe it would be good practice to add this to Custom HTML (every Confluence page).

            Deleted Account (Inactive) added a comment - - edited The solution I have found best for myself is to use jQuery to remove the element all together. I am running v5.5.2, of which the error message element does not have a class ( .error ) therefore I cannot use the solution mentioned by Zacharie Eakin. Keep in mind this may not be best for all releases of Confluence. <script> $( 'span:contains( "Unable to render {include}" )' ).parent().remove(); </script> I've only implemented this on a per page basis (as needed) using the HTML macro as I don't believe it would be good practice to add this to Custom HTML (every Confluence page).

            Zacharie Eakin added a comment - - edited

            Based off Jame's comment, if you want to suppress the rendering error via CSS you can do by putting the following snippet inside a HTML macro:

            <style type="text/css">
            .error

            { display:none; }

            </style>

            This just caused the error tag (which the rendering error is wrapped in) to be not displayed.

            The downside is that it will be per page, and will apply to all errors on the page - so no errors will be displayed at all.

            Zacharie Eakin added a comment - - edited Based off Jame's comment, if you want to suppress the rendering error via CSS you can do by putting the following snippet inside a HTML macro: <style type="text/css"> .error { display:none; } </style> This just caused the error tag (which the rendering error is wrapped in) to be not displayed. The downside is that it will be per page, and will apply to all errors on the page - so no errors will be displayed at all.

            In a similar vein, I'd like to be able to include content without bringing links along. Sometimes I want to include content from another space, but customers in space A can't access pages in space B, do they get error messages when they click on links that have come along fr the ride.

            Emily Johnson added a comment - In a similar vein, I'd like to be able to include content without bringing links along. Sometimes I want to include content from another space, but customers in space A can't access pages in space B, do they get error messages when they click on links that have come along fr the ride.

            First of all I've to thank Jochen for his comment - its that, what I feel and would sign fully.

            "Trolling" as you, James classified my words, is no sort of action or participation on any type of software, I use, but I'm a bit frustrated about what is coming back as support from Atlassian and our IT support says the same regarding support requests, they asked. Besides that, most requests (about error fixing, not only feature requests) I researched, I saw on very old versions detected and while new versions of Confluence gets a lot of new features, questions on this are generally answered: No time to fix or to complex to fix.

            Regarding Confluence, I'm a normal user. It has been set in our company and I've neither control over what to install for my needs, because all this could only be done by confluence system administrator. I'm only a space admin of one space in the confluence world. Also user macros (why they are named USER macros), changing css or further tipps you mentioned are under only control of the system administration. I could suggest changes in our installation, which I do, but to get them fullfilled I often have to give them a lot of technical and background information I do not have and I have no time to research, because of my normal job, I've to do - which is not managing our Confluence.

            Because this issue has been opened by atlassian themselves and another issue I found regarding same topic does last point to this one and because I was put automatically? on the watchers list, I saw the chance to get more feedback by issuing a comment with words, showing the importance - obviously not only for me (on counting the number of similar issues in the different versions).

            James,
            if you have another focus on Confluence and/or the knowledge, how to circumvent the several problems and errors (e.g. as this one), which gives me the problem, that I could not share my space with viewers with different rights, I'm very very interested in a detailed description, what I could the forward to or IT for integrating. Thanks in advance and have a nice weekend.

            Wolfgang Brodowski added a comment - First of all I've to thank Jochen for his comment - its that, what I feel and would sign fully. "Trolling" as you, James classified my words, is no sort of action or participation on any type of software, I use, but I'm a bit frustrated about what is coming back as support from Atlassian and our IT support says the same regarding support requests, they asked. Besides that, most requests (about error fixing, not only feature requests) I researched, I saw on very old versions detected and while new versions of Confluence gets a lot of new features, questions on this are generally answered: No time to fix or to complex to fix. Regarding Confluence, I'm a normal user. It has been set in our company and I've neither control over what to install for my needs, because all this could only be done by confluence system administrator. I'm only a space admin of one space in the confluence world. Also user macros (why they are named USER macros), changing css or further tipps you mentioned are under only control of the system administration. I could suggest changes in our installation, which I do, but to get them fullfilled I often have to give them a lot of technical and background information I do not have and I have no time to research, because of my normal job, I've to do - which is not managing our Confluence. Because this issue has been opened by atlassian themselves and another issue I found regarding same topic does last point to this one and because I was put automatically? on the watchers list, I saw the chance to get more feedback by issuing a comment with words, showing the importance - obviously not only for me (on counting the number of similar issues in the different versions). James, if you have another focus on Confluence and/or the knowledge, how to circumvent the several problems and errors (e.g. as this one), which gives me the problem, that I could not share my space with viewers with different rights, I'm very very interested in a detailed description, what I could the forward to or IT for integrating. Thanks in advance and have a nice weekend.

            JamesM added a comment -
            • My appologies, Jochen. You're report was not at all a troll, and is very helpful. My note was not at all directed at you. My comment was intended to suggest alternative courses of action for anyone who decides to write about how ineffective Atlassian is at addressing a particular issue, such as seems to be implied by Wolfgang above. I've simply noticed that, for myself, writing statements to try to invoke guilt does not encourage Atlassian to develop something new. However, building a case, collecting examples, linking together ideas and people, does work.
            • I'll refer you to atlassian support, the atlassian forums, or the help documentation for CSS restyling help.
            • check out the 'style' macro extemsion for page-specific styling.
            • also, check the 'show-to' and 'hide-from' confluence extensions for showing / hiding content to/from specific users.

            JamesM added a comment - My appologies, Jochen. You're report was not at all a troll, and is very helpful. My note was not at all directed at you. My comment was intended to suggest alternative courses of action for anyone who decides to write about how ineffective Atlassian is at addressing a particular issue, such as seems to be implied by Wolfgang above. I've simply noticed that, for myself, writing statements to try to invoke guilt does not encourage Atlassian to develop something new. However, building a case, collecting examples, linking together ideas and people, does work. I'll refer you to atlassian support, the atlassian forums, or the help documentation for CSS restyling help. check out the 'style' macro extemsion for page-specific styling. also, check the 'show-to' and 'hide-from' confluence extensions for showing / hiding content to/from specific users.

              Unassigned Unassigned
              ben@atlassian.com BenjaminA
              Votes:
              63 Vote for this issue
              Watchers:
              41 Start watching this issue

                Created:
                Updated: