Bug 1002308 - Cloning a channel via API fails if channel label starts with a digit.
Cloning a channel via API fails if channel label starts with a digit.
Status: ASSIGNED
Product: Red Hat Satellite 5
Classification: Red Hat
Component: API (Show other bugs)
560
Unspecified Unspecified
low Severity low
: ---
: ---
Assigned To: Tomas Lestach
Red Hat Satellite QA List
:
Depends On:
Blocks: 462714
  Show dependency treegraph
 
Reported: 2013-08-28 17:08 EDT by Dimitar Yordanov
Modified: 2015-08-10 15:43 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Dimitar Yordanov 2013-08-28 17:08:42 EDT
Description of problem:
Cloning a channel via API fails if channel label starts with a digit.

The problem is that the regular expression that verifies the channel label when the channel is cloned via API is not correct: 
 Pattern.compile("^[a-z][a-z\\d\\-\\.\\_]*$", Pattern.CASE_INSENSITIVE); 

The correct one is the one used when the channel is cloned on WebUI:
$channel_label =~ /^[a-z\d][a-z\d\-\.\_]*$/

Version-Release number of selected component (if applicable):
spacewalk-java-2.1.28-1

How reproducible:
100

Steps to Reproduce:
1. Execute the following script.

import sys, xmlrpclib
RHN_SERVER='https://xxxx.redhat.com/rpc/api'
RHN_USER='xxxx'
RHN_PASS='xxxx'
client = xmlrpclib.Server(RHN_SERVER, verbose=0)
key = client.auth.login(RHN_USER, RHN_PASS)

client.channel.software.create(key,'test_label','test_name','summary','channel-x86_64','')
client.channel.software.clone(key,'test_label',{'name':'clone-test_name','label':'222clone-test_label','summary':'test summary',},True)


Actual results:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1578, in __request
    verbose=self.__verbose
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1473, in parse_response
    return u.close()
  File "/usr/lib64/python2.7/xmlrpclib.py", line 793, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault -1: "redstone.xmlrpc.XmlRpcFault: unhandled internal exception: The channel parameter 222clone-test_label is invalid. It Must  be at least 6 characters long, begin with a letter, and contain only lowercase letters, digits, '-', '_', and '.'.  Also, it cannot begin with 'rhn', 'redhat', or 'red hat'.">


Expected results:
The channel is cloned successfully as it will happen if the same action was done on WebUI.

Additional info:
Comment 1 Dimitar Yordanov 2013-08-28 17:14:42 EDT
Fixed in Spacewalk Master: bec830185e23457cc913633c7a7fe7ac41a0183a
Comment 2 Tomas Lestach 2013-08-29 02:25:26 EDT
Making the Comment#1 public, as it is a commit to Spacewalk master.

Dimitar, this commit does not fix the described issue. The code you touched gets applied in case of channel cloning, but not creation.
However, if we touch the channel name and label regexp, we would like to re-use the regexp defined on one place - for webui and for api.

Please, either re-work the patch or revert it.

Changing to ASSIGNED.
Comment 3 Tomas Lestach 2013-08-29 08:12:47 EDT
> The code you touched gets applied in case of channel cloning, but not creation.

Taking back, this bus is about channel cloning. My fault.

Keeping on ASSIGNED, as I'll do the basic re-factoring.

Note You need to log in before you can comment on or make changes to this bug.