Comment 2 for bug 341950

Revision history for this message
Markus Korn (thekorn) wrote :

I did some debugging, and for me it looks like the http_etag attribute of an entry object is not updated properly as a result of a SEND request

markus@thekorn ~ % launchpad-shell --debug
send: 'GET /beta/ HTTP/1.1\r\nHost: api.staging.launchpad.net:443\r\nAccept-Encoding: identity\r\nAuthorization: OAuth realm="https://api.launchpad.net", oauth_nonce="92420252", oauth_timestamp="1237192827", oauth_consumer_key="just testing", oauth_signature_method="PLAINTEXT", oauth_version="1.0", oauth_token="DKXXXXXXXX", oauth_signature="&cNYYYYYYY"\r\nif-none-match: "6824f160547b20004d582a2e240f8317e4304abd"\r\nte: deflate, gzip\r\naccept: application/vd.sun.wadl+xml\r\nuser-agent: Python-httplib2/$Rev: 259 $\r\n\r\n'
reply: 'HTTP/1.1 304 Not Modified\r\n'
header: Date: Mon, 16 Mar 2009 08:40:28 GMT
header: Server: zope.server.http (HTTP)
header: Etag: "6824f160547b20004d582a2e240f8317e4304abd"
header: Vary: Cookie,Authorization,Accept
send: 'GET /beta/ HTTP/1.1\r\nHost: api.staging.launchpad.net:443\r\nAccept-Encoding: identity\r\nAuthorization: OAuth realm="https://api.launchpad.net", oauth_nonce="63109900", oauth_timestamp="1237192833", oauth_consumer_key="just testing", oauth_signature_method="PLAINTEXT", oauth_version="1.0", oauth_token="DKXXXXXXXX", oauth_signature="&cNYYYYYYY"\r\nif-none-match: "77546fc558d4a811ad4f71a3495af2e410a87c52"\r\nte: deflate, gzip\r\naccept: application/json\r\nuser-agent: Python-httplib2/$Rev: 259 $\r\n\r\n'
reply: 'HTTP/1.1 304 Not Modified\r\n'
header: Date: Mon, 16 Mar 2009 08:40:34 GMT
header: Server: zope.server.http (HTTP)
header: Etag: "77546fc558d4a811ad4f71a3495af2e410a87c52"
header: Vary: Cookie,Authorization,Accept
Welcome to launchpad-shell - an interactive shell using launchpadlib

You are using the following configuration:
  * credentials: <launchpadlib.credentials.Credentials object at 0x1830410>
  * service: https://api.staging.launchpad.net/beta/
  * cache: /home/markus/.launchpadlib/cache

In [1]: bug = launchpad.bugs[123456]
send: 'GET /beta/bugs/123456 HTTP/1.1\r\nHost: api.staging.launchpad.net:443\r\nAccept-Encoding: identity\r\nte: deflate, gzip\r\nAuthorization: OAuth realm="https://api.launchpad.net", oauth_nonce="10785042", oauth_timestamp="1237192858", oauth_consumer_key="just testing", oauth_signature_method="PLAINTEXT", oauth_version="1.0", oauth_token="DKXXXXXXXX", oauth_signature="&cNYYYYYYY"\r\naccept: application/json\r\nuser-agent: Python-httplib2/$Rev: 259 $\r\n\r\n'
reply: ''
send: 'GET /beta/bugs/123456 HTTP/1.1\r\nHost: api.staging.launchpad.net:443\r\nAccept-Encoding: identity\r\nte: deflate, gzip\r\nAuthorization: OAuth realm="https://api.launchpad.net", oauth_nonce="10785042", oauth_timestamp="1237192858", oauth_consumer_key="just testing", oauth_signature_method="PLAINTEXT", oauth_version="1.0", oauth_token="DKXXXXXXXX", oauth_signature="&cNYYYYYYY"\r\naccept: application/json\r\nuser-agent: Python-httplib2/$Rev: 259 $\r\n\r\n'
reply: 'HTTP/1.1 200 Ok\r\n'
header: Date: Mon, 16 Mar 2009 08:41:00 GMT
header: Server: zope.server.http (HTTP)
header: X-Powered-By: Zope (www.zope.org), Python (www.python.org)
header: Content-Type: application/json
header: Content-Length: 1918
header: Etag: "34f56522b90d32202b1c3d8a7c96cb6d093ed11b"
header: Vary: Cookie,Authorization,Accept
header: Via: 1.1 wildcard.staging.launchpad.net

In [2]: bug.http_etag
Out[2]: u'"34f56522b90d32202b1c3d8a7c96cb6d093ed11b"'

In [3]: bug.newMessage(content="Testing bug", subject="Testing add comment")
send: 'post /beta/bugs/123456 HTTP/1.1\r\nHost: api.staging.launchpad.net:443\r\nAccept-Encoding: identity\r\nContent-Length: 76\r\ncontent-type: application/x-www-form-urlencoded\r\nAuthorization: OAuth realm="https://api.launchpad.net", oauth_nonce="16919267", oauth_timestamp="1237192880", oauth_consumer_key="just testing", oauth_signature_method="PLAINTEXT", oauth_version="1.0", oauth_token="DKXXXXXXXX", oauth_signature="&cNYYYYYYY"\r\naccept: application/json\r\nuser-agent: Python-httplib2/$Rev: 259 $\r\n\r\n'
send: 'content=%22Testing+bug%22&ws.op=newMessage&subject=%22Testing+add+comment%22'
reply: 'HTTP/1.1 201 Created\r\n'
header: Date: Mon, 16 Mar 2009 08:41:21 GMT
header: Server: zope.server.http (HTTP)
header: X-Powered-By: Zope (www.zope.org), Python (www.python.org)
header: X-Content-Type-Warning: guessed from content
header: Content-Length: 0
header: Location: https://api.staging.launchpad.net/beta/amarok/+bug/123456/comments/13
header: Vary: Cookie,Authorization,Accept
header: Content-Type: text/plain
header: Via: 1.1 wildcard.staging.launchpad.net
send: 'GET /beta/amarok/+bug/123456/comments/13 HTTP/1.1\r\nHost: api.staging.launchpad.net:443\r\nAccept-Encoding: identity\r\nAuthorization: OAuth realm="https://api.launchpad.net", oauth_nonce="92760047", oauth_timestamp="1237192892", oauth_consumer_key="just testing", oauth_signature_method="PLAINTEXT", oauth_version="1.0", oauth_token="DKXXXXXXXX", oauth_signature="&cNYYYYYYY"\r\nif-none-match: "9af25b4bfebdd7460fc573dbfd829529bd060b93"\r\nte: deflate, gzip\r\naccept: application/json\r\nuser-agent: Python-httplib2/$Rev: 259 $\r\n\r\n'
reply: 'HTTP/1.1 200 Ok\r\n'
header: Date: Mon, 16 Mar 2009 08:41:33 GMT
header: Server: zope.server.http (HTTP)
header: X-Powered-By: Zope (www.zope.org), Python (www.python.org)
header: Content-Type: application/json
header: Content-Length: 567
header: Etag: "36f015400090b76c80a37ae427e68825dd39a491"
header: Vary: Cookie,Authorization,Accept
header: Via: 1.1 wildcard.staging.launchpad.net
Out[3]: <message at https://api.staging.launchpad.net/beta/amarok/+bug/123456/comments/13>

In [4]: bug.http_etag
Out[4]: u'"34f56522b90d32202b1c3d8a7c96cb6d093ed11b"'

For a following bug.lp_save() launchpadlib will use the "34f[...]" etag which is different to the etag on the server, this means "resource changed after request was send", which results in a precondition error

Markus