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

Will not load manufactures with "Empty Spool Weight" to 0 #521

Open
Rupp3r opened this issue Oct 28, 2024 · 5 comments
Open

Will not load manufactures with "Empty Spool Weight" to 0 #521

Rupp3r opened this issue Oct 28, 2024 · 5 comments
Labels
Bug Something isn't working

Comments

@Rupp3r
Copy link

Rupp3r commented Oct 28, 2024

Describe the bug
I added manufacture with a spool weight of 0 and now the manufactures tab will not load and give error 500.
The purpose of 0 spool weight is because I buy refills and I do not know the type and weight of the spool it will be put on.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Manufactures' tab
  2. Click on 'Create'
  3. Set a name and 'Empty Spool Weight' to 0
  4. Save
  5. See error

Expected behavior
A manufacturer added with a default spool weight of 0.

image

Spoolman Host (please complete the following information):

  • Installation type: Docker
  • Installed version: 0.20.0
  • OS and Distro: Ubuntu 24.04(Server)
  • Database type: Built-in SQLite

Desktop (please complete the following information):

  • OS: Windows, Android
  • Browser Chrome

Additional context
Output from Logs:


  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/fastapi/encoders.py", line 301, in jsonable_encoder

    for item in obj:

  File "/home/app/spoolman/spoolman/api/v1/vendor.py", line 137, in <genexpr>

    (Vendor.from_db(db_item) for db_item in db_items),

     ^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/app/spoolman/spoolman/api/v1/models.py", line 85, in from_db

    return Vendor(

           ^^^^^^^

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/pydantic/main.py", line 176, in __init__

    self.__pydantic_validator__.validate_python(data, self_instance=self)

pydantic_core._pydantic_core.ValidationError: 1 validation error for Vendor

empty_spool_weight

  Input should be greater than 0 [type=greater_than, input_value=0.0, input_type=float]

    For further information visit https://errors.pydantic.dev/2.7/v/greater_than

INFO:     172.20.0.1:52104 - "GET /api/v1/vendor?limit=20&offset=0&sort=id:asc HTTP/1.1" 500 Internal Server Error

ERROR:    Exception in ASGI application

Traceback (most recent call last):

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 411, in run_asgi

    result = await app(  # type: ignore[func-returns-value]

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__

    return await self.app(scope, receive, send)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__

    await super().__call__(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/applications.py", line 123, in __call__

    await self.middleware_stack(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__

    raise exc

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__

    await self.app(scope, receive, _send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/middleware/gzip.py", line 24, in __call__

    await responder(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/middleware/gzip.py", line 44, in __call__

    await self.app(scope, receive, self.send_with_gzip)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 65, in __call__

    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app

    raise exc

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app

    await app(scope, receive, sender)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/routing.py", line 756, in __call__

    await self.middleware_stack(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/routing.py", line 776, in app

    await route.handle(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/routing.py", line 485, in handle

    await self.app(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__

    await super().__call__(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/applications.py", line 123, in __call__

    await self.middleware_stack(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__

    raise exc

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__

    await self.app(scope, receive, _send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 65, in __call__

    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app

    raise exc

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app

    await app(scope, receive, sender)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/routing.py", line 756, in __call__

    await self.middleware_stack(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/routing.py", line 776, in app

    await route.handle(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/routing.py", line 297, in handle

    await self.app(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/routing.py", line 77, in app

    await wrap_app_handling_exceptions(app, request)(scope, receive, send)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app

    raise exc

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app

    await app(scope, receive, sender)

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/starlette/routing.py", line 72, in app

    response = await func(request)

               ^^^^^^^^^^^^^^^^^^^

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 278, in app

    raw_response = await run_endpoint_function(

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function

    return await dependant.call(**values)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/app/spoolman/spoolman/api/v1/vendor.py", line 136, in find

    content=jsonable_encoder(

            ^^^^^^^^^^^^^^^^^

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/fastapi/encoders.py", line 301, in jsonable_encoder

    for item in obj:

  File "/home/app/spoolman/spoolman/api/v1/vendor.py", line 137, in <genexpr>

    (Vendor.from_db(db_item) for db_item in db_items),

     ^^^^^^^^^^^^^^^^^^^^^^^

  File "/home/app/spoolman/spoolman/api/v1/models.py", line 85, in from_db

    return Vendor(

           ^^^^^^^

  File "/home/app/spoolman/.venv/lib/python3.11/site-packages/pydantic/main.py", line 176, in __init__

    self.__pydantic_validator__.validate_python(data, self_instance=self)

pydantic_core._pydantic_core.ValidationError: 1 validation error for Vendor

empty_spool_weight

  Input should be greater than 0 [type=greater_than, input_value=0.0, input_type=float]

    For further information visit https://errors.pydantic.dev/2.7/v/greater_than````
@Rupp3r Rupp3r added the Bug Something isn't working label Oct 28, 2024
@RoadkillUK
Copy link

I would like to add mine here too, I haven't added any spools lately but it has recenty started with the same error, similar logs. It loads and works fine, however I cannot add nor see any of the manufacturers.

Is there any way to fix the db?

File "/home/app/spoolman/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/app/spoolman/spoolman/api/v1/vendor.py", line 136, in find
content=jsonable_encoder(
^^^^^^^^^^^^^^^^^
File "/home/app/spoolman/.venv/lib/python3.11/site-packages/fastapi/encoders.py", line 301, in jsonable_encoder
for item in obj:
File "/home/app/spoolman/spoolman/api/v1/vendor.py", line 137, in
(Vendor.from_db(db_item) for db_item in db_items),
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/app/spoolman/spoolman/api/v1/models.py", line 85, in from_db
return Vendor(
^^^^^^^
File "/home/app/spoolman/.venv/lib/python3.11/site-packages/pydantic/main.py", line 176, in init
self.pydantic_validator.validate_python(data, self_instance=self)
pydantic_core.pydantic_core.ValidationError: 1 validation error for Vendor
empty_spool_weight
Input should be greater than 0 [type=greater_than, input_value=0.0, input_type=float]
For further information visit https://errors.pydantic.dev/2.7/v/greater_than

@crokett
Copy link

crokett commented Nov 5, 2024

I am having the same problem. If I create a manufacturer and then create a filament and select that manufacturer the empty spool weight is not populated. The recreate steps are the same as noted above.

Installation type: Native, no Docker
Installed version: 0.20.0
OS and Distro: Raspberry Pi OS
Database type: Built-in SQLite
Desktop (please complete the following information):

OS: Windows
Browser: MS Edge

@rreisrj
Copy link

rreisrj commented Nov 11, 2024

Same issue here, just added vendor "unknow"and "0" on Empty Spool Weight and stoped to load the vendors

Error 500
pydantic_core._pydantic_core.ValidationError: 1 validation error for Vendor
empty_spool_weight
Input should be greater than 0 [type=greater_than, input_value=0.0, input_type=float]
For further information visit https://errors.pydantic.dev/2.7/v/greater_than

Installation type: Native
Installed version: 0.20.0
OS and Distro: Ubuntu 22.04.5 LTS
Database type: Built-in SQLite

Desktop (please complete the following information):
OS: MacOS
Browser: Chrome

@rreisrj
Copy link

rreisrj commented Nov 13, 2024

OK, I just found a workaround!
You need to open the Spoolman.db located in ~/.local/share/spoolman for native installation or ./data for containers using a SQL browser like sqlitebrowser.org app.

Use the SQL command " select * from vendor " to check what rows on vendors table have the wrong value in empty_spool_weight column.

Now you need to delete or change the values on Vendor table.

To delete the Vendor with the incorrect spool value:

DELETE FROM vendor
WHERE name = 'VENDOR_NAME';

or change the spool value on all Vendors that have the wrong value, in this case is 0.0:

UPDATE vendor
SET empty_spool_weight = 200
WHERE empty_spool_weight = 0.0;

use the SQL command " select * from vendor " to make sure all the values are deleted or changed correctly, then select write changes to save the changes in the DB.

make sure the permissions are correct, if not use chmod to change it.
After those changes everything is working fine now, no data was lost.

I hope this helps!

@Rupp3r
Copy link
Author

Rupp3r commented Nov 15, 2024

@rreisrj Thank you 🙏🏻
I can now add new manufactures again! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants