Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to access SQS message body throws an exception as of boto3 versions 0.0.3 and 0.0.2 #33

Closed
zen4ever opened this issue Dec 1, 2014 · 2 comments · Fixed by #34
Closed
Assignees
Labels
bug This issue is a confirmed bug.

Comments

@zen4ever
Copy link

zen4ever commented Dec 1, 2014

import boto3

queue_url = ""

sqs = boto3.resource('sqs')
queue = sqs.Queue(queue_url)
messages = queue.receive_messages()
msg = messages[0]
print(msg.body)

It gives:

 File "****", line 31, in perform_action
    print(msg.body)
  File "****lib/python2.7/site-packages/boto3/resources/factory.py", line 262, in property_loader
    '{0} has no load method'.format(self.__class__.__name__))
ResourceLoadException: sqs.Message has no load method

It worked in 0.0.1

@zen4ever zen4ever changed the title Trying to access SQS message body throws an exception as of boto3 version 0.0.3 Trying to access SQS message body throws an exception as of boto3 versions 0.0.3 and 0.0.2 Dec 1, 2014
@danielgtaylor danielgtaylor added the bug This issue is a confirmed bug. label Dec 2, 2014
@danielgtaylor danielgtaylor self-assigned this Dec 2, 2014
@danielgtaylor
Copy link
Member

Confirmed. I'm looking into what is happening here with the .meta['data'] member not being set up correctly when autoloading resources from a response.

@danielgtaylor
Copy link
Member

@zen4ever this regression is due to a change in the underlying resource description JSON format. It was not caught by existing tests because:

  1. The tests assumed the older version of the format.
  2. The new format only moved a path value in certain conditions, in other conditions it is still valid as-is. This is why most things continue to just work.
  3. The collection-related integration tests only use identifiers, not resource data members.

I am working on a fix locally and will put up a pull request shortly.

danielgtaylor added a commit that referenced this issue Dec 2, 2014
This change adds support for the latest version of the JSON description files
for resources. The following has changed:

1. An action's `.path` has been moved into `.resource.path` if a resource
   is present. If it is present, then a path outside of the resource is
   no longer valid. This fixes #33.
2. Sub-resources previously defined with either `hasOne` or `hasMany` are now
   defined with a single `belongsTo` key. The internal Boto 3 representation,
   however, remains the same and is accessed via `resource.references`.

As a result of the format changes, I had to update the internal resource
model, adjust the search path behavior for actions and update various tests
that made assumptions about the older format.

I also discovered that we were using a mix of old and new files for different
services, so this change includes updates to EC2 and Glacier so that all
resources are using the new format. With this change, we no longer support
the older format.
danielgtaylor added a commit that referenced this issue Dec 3, 2014
This adds integration tests that exercise previously untested functionality,
specifically this adds the following to the existing describe calls:

* Create and delete remote resources
* Call actions to put and get data from remote resources
* Handle low-level responses from a service
* Exercise low-level waiters (to be replaced with high-level waiters)
* Access data attributes of pre-loaded resources with no `load` method

The last item would have prevented #33. This PR is related to #34,
which fixed the underlying issue that this test would have caught.

The full integration test suite now takes around 20-30 seconds on
my machine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants