MAAS often fails and and returns a Pickled object if request header is set to Accept: */*

Bug #1929643 reported by Lee Trager
30
This bug affects 5 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Medium
Alberto Donato
3.0
Fix Released
Medium
Alberto Donato

Bug Description

A customer has asked me to help them with their MAAS client. While implementing a very simple client I have noticed that MAAS almost always rejects the first request. When it does work it returns a Python pickled object. This ended up being because I was using python-requests which sets the default accept header to "*/*". If I set the accept header to "application/json" or even an empty string the request works.

MAAS should always return JSON when accept is set to '*/*', '*', '', or not defined.

Related branches

Lee Trager (ltrager)
summary: - MAAS often fails and and returns a Picked object if request header is
+ MAAS often fails and and returns a Pickled object if request header is
set to Accept: */*
description: updated
Revision history for this message
Alberto Donato (ack) wrote :

Could you please provide steps to reproduce this?

Changed in maas:
status: Triaged → Incomplete
Revision history for this message
Lee Trager (ltrager) wrote :

Run the attached script as follows:

./maas -k $USER_API_KEY http://$REGION_IP:5240/MAAS/api/2.0/machines/

Most of the time you'll get

ERROR: status code - 500

expected string or bytes-like object

On line 22 uncomment 'headers["Accept"] = "application/json"' and now the call works.

Changed in maas:
status: Incomplete → Triaged
Revision history for this message
Lee Trager (ltrager) wrote :

This version has headers["Accept"] = "application/json" commented, the other version has it uncommented.

Alberto Donato (ack)
Changed in maas:
assignee: nobody → Alberto Donato (ack)
status: Triaged → In Progress
importance: High → Medium
Alberto Donato (ack)
Changed in maas:
milestone: 3.0.0-rc2 → 3.0.1
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
milestone: 3.0.1 → none
Changed in maas:
milestone: none → 3.1.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments