Error messages about bad API requests are unhelpful and dense

Bug #1376305 reported by Andreas Hasenack
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Won't Fix
High
Unassigned

Bug Description

Fresh install of 1.7.0~beta4+bzr3143-0ubuntu1~trusty1

Whilst an image import was going on, API calls were being issued to switch the boot sources.

$ maas scapestack boot-source-selection update b08a5826-50d5-4cad-96ce-b9fbf6add610 1 labels=daily
invalid literal for int() with base 10: 'b08a5826-50d5-4cad-96ce-b9fbf6add610'

tailing the logs "just because", and I see this:

==> /var/log/maas/maas-django.log <==
ERROR 2014-10-01 14:51:03,011 maasserver ################################ Exception: invalid literal for int() with base 10: 'b08a5826-50d5-4cad-96ce-b9fbf6add610' ################################
ERROR 2014-10-01 14:51:06,054 maasserver Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 112, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python2.7/dist-packages/django/views/decorators/vary.py", line 19, in inner_func
    response = func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/piston/resource.py", line 167, in __call__
    result = self.error_handler(e, request, meth, em_format)
  File "/usr/lib/python2.7/dist-packages/piston/resource.py", line 165, in __call__
    result = meth(request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/maasserver/api/support.py", line 189, in dispatch
    return function(self, request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/maasserver/api/boot_source_selections.py", line 149, in read
    BootSource, id=boot_source_id)
  File "/usr/lib/python2.7/dist-packages/django/shortcuts/__init__.py", line 113, in get_object_or_404
    return queryset.get(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 298, in get
    clone = self.filter(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 590, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 608, in _filter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))
  File "/usr/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1198, in add_q
    clause = self._add_q(where_part, used_aliases)
  File "/usr/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1232, in _add_q
    current_negated=current_negated)
  File "/usr/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 1125, in build_filter
    clause.add(constraint, AND)
  File "/usr/lib/python2.7/dist-packages/django/utils/tree.py", line 104, in add
    data = self._prepare_data(data)
  File "/usr/lib/python2.7/dist-packages/django/db/models/sql/where.py", line 79, in _prepare_data
    value = obj.prepare(lookup_type, value)
  File "/usr/lib/python2.7/dist-packages/django/db/models/sql/where.py", line 352, in prepare
    return self.field.get_prep_lookup(lookup_type, value)
  File "/usr/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 369, in get_prep_lookup
    return self.get_prep_value(value)
  File "/usr/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 613, in get_prep_value
    return int(value)
ValueError: invalid literal for int() with base 10: 'b08a5826-50d5-4cad-96ce-b9fbf6add610'

tags: added: landscape
summary: - int() got an uuid, crashed
+ Bad API call leads to: int() got an uuid, crashed
Changed in maas:
milestone: none → 1.7.0
Revision history for this message
Graham Binns (gmb) wrote : Re: Bad API call leads to: int() got an uuid, crashed

Assigning this to Blake as it looks like it could be a problem with the boot resources code.

tags: added: boot-images
Changed in maas:
assignee: nobody → Blake Rouse (blake-rouse)
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Where the boot sources modified in anyway? As I am seeing a UUID, which boot sources do not use.

Changed in maas:
status: New → Incomplete
Revision history for this message
Graham Binns (gmb) wrote :

Blake, I'm sorry, my mistake… I read "/usr/lib/python2.7/dist-packages/maasserver/api/boot…" and just decided to blame boot sources :).

This looks like bad API validation, in fact.

Revision history for this message
Adam Collard (adam-collard) wrote :

Eeek, you guys jumped on this too quickly :) just updated description to explain what was going on (two of us weren't coordinating on MAAS setup. My bad!)

description: updated
Changed in maas:
status: Incomplete → Confirmed
Changed in maas:
status: Confirmed → New
Graham Binns (gmb)
Changed in maas:
assignee: Blake Rouse (blake-rouse) → nobody
assignee: nobody → Graham Binns (gmb)
status: New → In Progress
Revision history for this message
Graham Binns (gmb) wrote :

Ha, okay… So Adam, what you're saying is that your command was shonky and that MAAS puked on your shoes rather than giving you a helpful error?

If so, I think this should not be a 1.7 priority; that needs a more comprehensive fix.

Revision history for this message
Adam Collard (adam-collard) wrote :

The way I see it, there are two sides to the bug,

1. The CLI client for the API should validate before it sends garbage to the server.
2. The server shouldn't throw up so noisily because of garbage input.

I'm fine with not having 1 if 2 means the CLI gets a nice error message back.

Revision history for this message
Graham Binns (gmb) wrote :

Removing this from 1.7 as it needs a proper coat of looking-at.

Changed in maas:
status: In Progress → Triaged
importance: Undecided → High
summary: - Bad API call leads to: int() got an uuid, crashed
+ Error messages about bad API requests are unhelpful and dense
Changed in maas:
milestone: 1.7.0 → none
Graham Binns (gmb)
Changed in maas:
assignee: Graham Binns (gmb) → nobody
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Dear user,

This is an automated message.

We believe this bug report is no longer an issue in the latest version of MAAS. For such reason, we are making this issue as Won't Fix. If you believe this issue is still present in the latest version of MAAS, please re-open this bug report.

Changed in maas:
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.