With a proxy, snap info endpoint fails if "revision" not in requested fields

Bug #1836103 reported by Jonathan Hartley
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snap Store Server
Fix Released
Low
Unassigned

Bug Description

Given a store proxy.

When a call is made to /v2/snap[s/info/{name}?fields=snap-id
(ie. any set of fields that does not include 'revision')

Then the a 200 response is expected with the specified fields,
but instead we get an error response.

I'm unhelpfully not specifying the error because I haven't reproduced this against a running server, only seen it happen in the tests:

eg. in devicegw source, modify the assignment of 'fields' at the start of OverrideWithLocalSnaprevsTests.test_specific_fields, to remove 'revision'. This results in:

```
ERROR: test_specific_fields (snapdevicegw.tests.test_webapi_info.OverrideWithLocalSnaprevsTests)
snapdevicegw.tests.test_webapi_info.OverrideWithLocalSnaprevsTests.test_specific_fields
----------------------------------------------------------------------
testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/jhartley/src/snapdevicegw/snapdevicegw/tests/test_webapi_info.py", line 581, in test_specific_fields
    response = self.do_request(snap_name, query=query)
  File "/home/jhartley/src/snapdevicegw/snapdevicegw/tests/test_webapi_info.py", line 416, in do_request
    response = self.fixture.client.get(urlpath, headers=headers)
... [snip] ...
  File "/home/jhartley/src/snapdevicegw/snapdevicegw/webapi_info.py", line 159, in get_snap_info
    results = _override_with_local_snaprevs(snap_name, upstream_data)
  File "/home/jhartley/src/snapdevicegw/snapdevicegw/webapi_info.py", line 241, in _override_with_local_snaprevs
    snap_name, snap_id, snap_ident_data, channel_map)
  File "/home/jhartley/src/snapdevicegw/snapdevicegw/proxy.py", line 368, in override_snap_info
    upstream_channel_map)
  File "/home/jhartley/src/snapdevicegw/snapdevicegw/proxy.py", line 325, in _transform_snap_info_external_to_internal
    'revision': up_item['revision'],
KeyError: 'revision'
```

The source there indexes by 'revision', instead of using .get() as is done for other fields on adjacent lines, but a quick skim of the source there looks nontrivial to fix, so I'm filing a bug for now.

I'm a newhire, please shout at me if this bug report is lacking in some way. Thanks.

description: updated
description: updated
Revision history for this message
Przemysław Suliga (suligap) wrote :

This is fixed. It was tracked in a duplicate of this bug at https://bugs.launchpad.net/snapstore-snap/+bug/1942892

Changed in snapstore-server:
status: New → Fix Released
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.