Ticket #510 (closed defect: fixed)

Opened 11 months ago

Last modified 11 months ago

encoding error with dictionary keys pointing to the same object

Reported by: aball Owned by: nick
Priority: critical Milestone: 0.4.2
Component: Remoting Version: 0.4.1
Keywords: Cc:
Fixed in revision: 2284 Branch: remoting-encode-510
Author: nick

Description

I've noticed what looks like an encoding error when I make requests like the following:

address = {'street_1' : '221B Baker Street', 'city' : 'London',
    'country' : 'UK'}
print svc.demonstrate_issue({'groups' : [1], 'shipping_address' : address,
    'billing_address' : address})

The 'shipping_address' and 'billing_address' elements in the dictionary should be received as pointing to the same dictionary on the server side. However, I see either 'shipping_address' or 'billing_address' pointing to the same element that 'groups' does, which is a list in this case.

I'm using Django 1.0.2 with PyAMF's Django gateway as the server. I'm attaching a small Django project and sample client that demonstrates the issue. After downloading and extracting the attachment, here's all you need to do to reproduce the issue:

aball@ws36:~/devel/PyAMF_encoding_issue$ cd pyamf_encoding_issue/
aball@ws36:~/devel/PyAMF_encoding_issue/pyamf_encoding_issue$ python manage.py runserver
Validating models...
0 errors found

Django version 1.0.2 final, using settings 'pyamf_encoding_issue.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

aball@ws36:~/devel/PyAMF_encoding_issue/pyamf_encoding_issue$ python manage.py runserver
Validating models...
0 errors found

# in a different shell
aball@ws36:~/devel/PyAMF_encoding_issue$ python client.py
type(param_dict['groups']) = <type 'list'>
id(param_dict['groups']) = 142635884

type(param_dict['shipping_address']) = <type 'list'>
id(param_dict['shipping_address']) = 142635884

type(param_dict['billing_address']) = <class 'pyamf.ASObject'>
id(param_dict['billing_address']) = 140392892

Attachments

PyAMF_encoding_issue.tar.gz Download (3.7 KB) - added by aball 11 months ago.
small Django app and client to demonstrate the problem

Change History

Changed 11 months ago by aball

small Django app and client to demonstrate the problem

Changed 11 months ago by aball

I have made the same request through ActionScript 3.0 without the issue. I've also tried against the PyAMF trunk at revision 2276 (last changed 2264) with the same results.

Changed 11 months ago by nick

  • priority changed from major to critical
  • status changed from new to accepted
  • component changed from Client to Remoting

This appears to be an issue with the remoting module as this test indicates:

import pyamf

address = {'street_1' : '221B Baker Street', 'city' : 'London',
    'country' : 'UK'}

parent = {'groups' : [1], 'shipping_address' : address,
    'billing_address' : address}

s = pyamf.encode(parent).getvalue()

parent = pyamf.decode(s).next()

assert id(parent['billing_address']) == id(parent['shipping_address'])

Changed 11 months ago by nick

  • branch set to remoting-encode-510

Turns out the when encoding a remoting message the initial body would be included as part of the object reference collection.

This is the wrong behaviour.

Changed 11 months ago by nick

  • keywords review added
  • owner nick deleted
  • status changed from accepted to assigned

I have committed a fix for this in r2278. I have also tested with EchoTest and all looks good.

Changed 11 months ago by nick

The attached example also reports back the correct results:

type(param_dict['groups']) = <type 'list'>
id(param_dict['groups']) = 26120920

type(param_dict['shipping_address']) = <class 'pyamf.ASObject'>
id(param_dict['shipping_address']) = 27480872

type(param_dict['billing_address']) = <class 'pyamf.ASObject'>
id(param_dict['billing_address']) = 27480872

Changed 11 months ago by nick

Once this lands on trunk we should have another point release for PyAMF - 0.4.2

Changed 11 months ago by thijs

  • milestone set to 0.4.2
  • author set to nick

Changed 11 months ago by thijs

#500 was closed as a duplicate of this ticket.

Changed 11 months ago by thijs

  • keywords review removed
  • owner set to nick

Tested with the test client and server from ticket #500 and the issue we were having there is fixed now. Please merge.

Changed 11 months ago by nick

  • status changed from assigned to closed
  • revfixed set to 2284
  • resolution set to fixed
Note: See TracTickets for help on using tickets.