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

test chunk_preupload_and_download fails with server v0.11.0 #41

Open
neduard opened this issue Mar 24, 2023 · 0 comments
Open

test chunk_preupload_and_download fails with server v0.11.0 #41

neduard opened this issue Mar 24, 2023 · 0 comments

Comments

@neduard
Copy link

neduard commented Mar 24, 2023

Description

Hello! So I wanted to play a bit with the server and maybe put together an app.

I tried running the etebase-rs tests against a recent server instance. note I'm not deploying via docker: I'm simply running the current version of the server.

Hope this is an actual issue and not due to something silly on my side like a version mismatch 🙈

The test chunk_preupload_and_download seems to fail with Error: ServerError("Server error")

failures:

---- chunk_preupload_and_download stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /build/rustc-Oic09u/rustc-1.65.0+dfsg0ubuntu1/library/test/src/lib.rs:184:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Steps to reproduce:

  • run the server from the most recent commit. Note you'll need to comment out the ETEBASE_CREATE_USER_FUNC so that the tests can create new users.
diff --git a/etebase_server/settings.py b/etebase_server/settings.py
index 97ec7e9..63fcc21 100644
--- a/etebase_server/settings.py
+++ b/etebase_server/settings.py
@@ -140,7 +140,7 @@ config_locations = [
     "/etc/etebase-server/etebase-server.ini",
 ]
 
-ETEBASE_CREATE_USER_FUNC = "etebase_server.django.utils.create_user_blocked"
+#ETEBASE_CREATE_USER_FUNC = "etebase_server.django.utils.create_user_blocked"
 
 # Use config file if present
 if any(os.path.isfile(x) for x in config_locations):

  • run using vicorn etebase_server.asgi:application --host 0.0.0.0 --port 8000 --reload

Further debugging

I did a bit of digging:

The error happens here:

it_mgr.upload_content(&item)?;

This fails because it's trying to send binary data, but put_inner still calls prep_client and with_base_client which sets the Content-Type: application/msgpack header.

Now a workaround is fairly easy:

--- a/etebase_server/fastapi/msgpack.py
+++ b/etebase_server/fastapi/msgpack.py
@@ -18,6 +18,9 @@ class MsgpackRequest(Request):
             self._json = msgpack_decode(body)
         return self._json
 
+    async def raw(self) -> bytes:
+        return await super().body()
+
 
 class MsgpackResponse(Response):
     media_type = "application/msgpack"
diff --git a/etebase_server/fastapi/routers/collection.py b/etebase_server/fastapi/routers/collection.py
index c847743..8bd9211 100644
--- a/etebase_server/fastapi/routers/collection.py
+++ b/etebase_server/fastapi/routers/collection.py
@@ -610,7 +610,7 @@ async def chunk_update(
     collection: models.Collection = Depends(get_collection),
 ):
     # IGNORED FOR NOW: col_it = get_object_or_404(col.items, uid=collection_item_uid)
-    content_file = ContentFile(await request.body())
+    content_file = ContentFile(await request.raw())
     try:
         await chunk_save(chunk_uid, collection, content_file)
     except IntegrityError:

Though I don't think this is the right way of doing things? I'm happy to put together a PR though if someone can point me in the right direction.

Many Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant