Merge ~j.kylmala/cloud-init:exceptions into cloud-init:master

Proposed by Joonas Kylmälä
Status: Merged
Merged at revision: b6c478e07008819ea1a69a666f3a97c89f457e19
Proposed branch: ~j.kylmala/cloud-init:exceptions
Merge into: cloud-init:master
Diff against target: 15 lines (+2/-2)
1 file modified
tools/mock-meta.py (+2/-2)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
cloud-init Commiters Pending
Review via email: mp+327284@code.launchpad.net

Commit message

tools: Fix exception handling.

We should be expecting IndexError instead of KeyError because we are
using a list (key_ids) and not a dictionary. Also, thanks to Emmanuel
Kasper for pointing out the wrong response code.

LP: #1701527

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:ec81bec2285a498c2c754572755929d983db3ef8
https://jenkins.ubuntu.com/server/job/cloud-init-ci/36/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    SUCCESS: CentOS 6 & 7: Build & Test
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/36/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/mock-meta.py b/tools/mock-meta.py
2index f185dbf..a5d14ab 100755
3--- a/tools/mock-meta.py
4+++ b/tools/mock-meta.py
5@@ -262,8 +262,8 @@ class MetaDataHandler(object):
6 except ValueError:
7 raise WebException(hclient.BAD_REQUEST,
8 "%s: not an integer" % mybe_key)
9- except KeyError:
10- raise WebException(hclient.BAD_REQUEST,
11+ except IndexError:
12+ raise WebException(hclient.NOT_FOUND,
13 "Unknown key id %r" % mybe_key)
14 # Extract the possible sub-params
15 result = traverse(nparams[1:], {

Subscribers

People subscribed via source and target branches