Open Source Snap-Store getting EOF


I forked the old open-source snap store implementation and am trying to fix it and make it work again. Right now, I am working on a pass-through method, so if it doesn’t find a snap on the self-hosted store, it then looks it up on the official store.

Everything works fine, except for assertions, which are preventing snaps from being installed. They spit out the error “Unexpected EOF.” I wrote some debug code in it, and if I manually put it in a browser, everything works fine. Even my example says in it’s logs: returned 406 bytes <200 OK>. It returns them in JSON, just like the “snap find” code.


def _assertion(value):
    # passthrough to upstream if we don't have that snap
    # TODO: global toggle for passthrough
    # TODO: enable assertions for Snaps on this store (only works for passthrough for now)
    h = {k: v for (k, v) in request.headers if k in HEADERS}
    #, headers=h
    r = requests.get(USTORE + '/snaps/assertions/snap-revision/%s' % value, headers=h)
    # print(r.json(), file=sys.stderr)
    return r.json()

def assertion(value):
    pkg2 = _assertion(value)
    print("DEBUG: "+json.dumps(pkg2))
    print(Response(json.dumps(pkg2)), file=sys.stderr)
    return Response(json.dumps(pkg2), mimetype='application/json')

The reason I find this baffling is because I have very similar code for handling “snap find” queries and it works fine, but similar code, modified to pass-through for assertions, gives me Unexpected EOF. I know EOF stands for “end of file”, but I can’t figure out why it is doing that. Everything seems to be working fine, because if I manually test, it spits out the assertion as it is, without a problem.

As far as I know, my snap store example is working fine, but snapd can’t read the results properly.


P.S. Remember, this is pass-through. It isn’t using it’s own assertions. It is just passing along the assertions already in the store.