Bug 1171671

Summary: catching wrong exception if testcase has no caseplan
Product: [Fedora] Fedora Reporter: Ales Zelinka <azelinka>
Component: python-nitrateAssignee: Petr Šplíchal <psplicha>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 22CC: isenfeld, ohudlick, psplicha
Target Milestone: ---Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-nitrate-1.3-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-22 07:56:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
proposed patch none

Description Ales Zelinka 2014-12-08 10:53:29 UTC
Description of problem:
Traceback (most recent call last):
  File "/usr/bin/tcms-plan", line 427, in <module>
    errata, general_plan)
  File "/usr/bin/tcms-plan", line 281, in create_update_plan
    testcases = set([case for case in general_plan
  File "/usr/lib/python2.6/site-packages/nitrate/mutable.py", line 184, in __iter__
    for testcase in self.testcases:
  File "/usr/lib/python2.6/site-packages/nitrate/containers.py", line 779, in __iter__
    self._items, key=lambda x: self._object.sortkey(x)):
  File "/usr/lib/python2.6/site-packages/nitrate/containers.py", line 779, in <lambda>
    self._items, key=lambda x: self._object.sortkey(x)):
  File "/usr/lib/python2.6/site-packages/nitrate/mutable.py", line 368, in sortkey
    if caseplan.testcase == testcase][0]
IndexError: list index out of range


The code is 
        try:
            caseplan = [caseplan for caseplan in self.caseplans
                    if caseplan.testcase == testcase][0]
        except KeyError:
            raise NitrateError("No CasePlan for {0} in {1} found".format(
                    testcase.identifier, self.identifier))

It should except IndexError since we're accessing an array. Or maybe a LookupError if both array and dectionary lookup might fail.

Comment 1 Jaroslav Reznik 2015-03-03 16:34:34 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22

Comment 2 Iveta Wiedermann 2016-02-04 12:03:11 UTC
Created attachment 1121087 [details]
proposed patch

Exception changed from KeyError to LookupError.

Comment 3 Petr Šplíchal 2016-02-09 17:18:59 UTC
Thanks for the patch, Iveta. Merged into master:
https://github.com/psss/python-nitrate/commit/e902887

Comment 4 Fedora Update System 2016-02-10 11:51:43 UTC
python-nitrate-1.3-1.el6 has been submitted as an update to Fedora EPEL 6. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-687d19409b

Comment 5 Fedora Update System 2016-02-10 11:55:50 UTC
python-nitrate-1.3-1.el7 has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-35a106d076

Comment 6 Fedora Update System 2016-02-10 11:57:31 UTC
python-nitrate-1.3-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2016-2bb9364c32

Comment 7 Fedora Update System 2016-02-10 11:58:21 UTC
python-nitrate-1.3-1.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-7474e957a9

Comment 8 Petr Šplíchal 2016-02-10 12:50:22 UTC
Latest packages for testing available in the copr repository:
https://copr.fedorainfracloud.org/coprs/psss/python-nitrate/

Comment 9 Fedora Update System 2016-02-10 17:20:01 UTC
python-nitrate-1.3-1.el6 has been pushed to the Fedora EPEL 6 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-687d19409b

Comment 10 Fedora Update System 2016-02-10 18:22:36 UTC
python-nitrate-1.3-1.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-2bb9364c32

Comment 11 Fedora Update System 2016-02-10 18:50:37 UTC
python-nitrate-1.3-1.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-7474e957a9

Comment 12 Fedora Update System 2016-02-10 23:54:08 UTC
python-nitrate-1.3-1.el7 has been pushed to the Fedora EPEL 7 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-35a106d076

Comment 13 Fedora Update System 2016-02-21 02:22:01 UTC
python-nitrate-1.3-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.

Comment 14 Fedora Update System 2016-02-21 16:27:16 UTC
python-nitrate-1.3-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2016-02-27 02:01:02 UTC
python-nitrate-1.3-1.el6 has been pushed to the Fedora EPEL 6 stable repository. If problems still persist, please make note of it in this bug report.

Comment 16 Fedora Update System 2016-02-27 02:07:50 UTC
python-nitrate-1.3-1.el7 has been pushed to the Fedora EPEL 7 stable repository. If problems still persist, please make note of it in this bug report.