confluence labels remain after cli reportes removal
Asked by Peter Kahn:

Hi all,

I have a script (shown below) that traverses all pages in a space and removes labels. This works great for some cases but not all. If I create a new space, add pages and labels the script cleans them nicely. If I use on of my javadoc spaces which has 4000+ labels the script reports label removal, but the labels remain.

**Example Output:**

PAGE: my page  
LBLS: FooBar  
Labels: 'FooBar ' were removed from item: 'my page' from space: 'javadoc'   
remaining LBLS: FooBar

I exported the space to xml and looked at the labels. I see nothing special about them. I am concerned by the trailing space on the labels output. I tried executing the command manually and I get the same result. I'm not sure what is blocking the removal.

Please let me know if you see an issue that I'm missing. I'm going to dig into the source code.

Thanks

Peter

```
#!/usr/bin/env bashfunction listLabels{	space=$1	page=$2	./confluence.sh -a getLabelList --space $space --title "$page"|egrep -v 'labels in list'|sed ':a;N;$!ba;s/\n/,/g;s/,$//'}function listPages{	space=$1	echo Creating PageList ${space}.pages ...	./confluence.sh -a getPageList --space $space |egrep -v 'pages in list' &gt; ${space}.pages	echo PageList Complete...}function removeLabelsFromPage {	space=$1	page=$2	labels=`listLabels $space "$page"`	echo PAGE: $page	echo LBLS: $labels	./confluence.sh -a removeLabels --space $space --title "$page" --labels $labels        echo remaining LBLS: `listLabels $space "$page"`	echo "-----------"}function removeLabelsFromSpacePages{	space=$1	pageListFile=$2	while read line	do 	removeLabelsFromPage $space "$line"	done &lt; ${pageListFile}}## ---------------------## MAIN## ---------------------space=$1listPages $spaceremoveLabelsFromSpacePages $space ${space}.pages
```


Answers:
author: Bob Swift (personal)
body: Probably you are running into an historical inconsistency in the CLI. Confluence CLI uses: **Comma separated list of labels**. JIRA CLI uses a blank separated list (which is better in this case). Confluence CLI should be changed to support both, but for now use a comma. Please [open an issue](https://bobswift.atlassian.net/secure/CreateIssue!default.jspa) for the change.

comments: author: Peter Kahn
body: Thanks Bob, but it fails on a list on one as well. There must be something special about the label in question. 'HasFields'. Is the repository in bit bucket? I found cli, but not confluence cli. I want to take a stab at debugging this one.Peter


author: Bob Swift (personal)
body: Please [open an issue](https://bobswift.atlassian.net/secure/CreateIssue!default.jspa) and provide an example of the CLI actions run using **-v** parameter. The bitbucket repository is now private, you will have to use the older version source zip.


author: Peter Kahn
body: Ah figured out the problem. My space generator takes javadoc and builds a space xml out of it. It splits the package names into labels but doesn't track and re-use labels. So, I have 200 + "com" labels. I think this is why I ran into the problems. I fixed the generator code and I think Atlassian fixed import so duplicate labels are no longer a problem.

Thanks for the comments. I think this is self manufacturered.


Tags: cli