Skip to content

Commit

Permalink
Merge pull request #57 from viniciusarcanjo/dpid_not_found
Browse files Browse the repository at this point in the history
return 404 status code when dpid is not found
  • Loading branch information
beraldoleal authored Apr 5, 2018
2 parents 658b0d4 + 936f89f commit cb3af0c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def _send_flow_mods_from_request(self, dpid, command):
else:
switches = [self.controller.get_switch_by_dpid(dpid)]

if None in switches:
return jsonify({"reponse": "dpid not found"}), 404

for switch in switches:
serializer = self._get_flow_serializer(switch)
flows = flows_dict.get('flows', [])
Expand Down

4 comments on commit cb3af0c

@hdiogenes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code contains a typo: "reponse".

Also, it could return 404 in the hypothetical case of multiple switches being returned (eg.: [valid_switch1, valid_switch2, None]). The code would be more correct if None instances were filtered out (using filter(None, switches), for example).

@beraldoleal
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hdiogenes nice catch. :) Can you or @viniciusarcanjo send a fix, sorry, but I already accepted.

@hdiogenes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed the typo directly in master: 35c56d7

@viniarck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hdiogenes. I missed this notification. My bad.

Please sign in to comment.