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

[Bug Report] Empty field ports of first app in template will trigger an Internal Server Error #173

Closed
yangkghjh opened this issue Oct 18, 2020 · 8 comments

Comments

@yangkghjh
Copy link

Error message

Template update failed. ERR_001 local variable 'ports' referenced before assignment
INFO:      - "GET /api/templates/3/refresh HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py", line 390, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/usr/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "/usr/lib/python3.8/site-packages/fastapi/applications.py", line 180, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/lib/python3.8/site-packages/starlette/applications.py", line 111, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/usr/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/usr/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/usr/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/usr/lib/python3.8/site-packages/starlette/routing.py", line 566, in __call__
    await route.handle(scope, receive, send)
  File "/usr/lib/python3.8/site-packages/starlette/routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "/usr/lib/python3.8/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
  File "/usr/lib/python3.8/site-packages/fastapi/routing.py", line 196, in app
    raw_response = await run_endpoint_function(
  File "/usr/lib/python3.8/site-packages/fastapi/routing.py", line 149, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/usr/lib/python3.8/site-packages/starlette/concurrency.py", line 34, in run_in_threadpool
    return await loop.run_in_executor(None, func, *args)
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "./api/routers/templates.py", line 65, in refresh_template
    return crud.refresh_template(db=db, template_id=id)
  File "./api/db/crud/templates.py", line 164, in refresh_template
    ports=ports,
UnboundLocalError: local variable 'ports' referenced before assignment
@yangkghjh
Copy link
Author

It's hard to debug when I import a large template. Hope to print the name of the error app.

@SelfhostedPro
Copy link
Owner

Ah, it should still run through the loop there. Are you defining ports as empty or just skipping the ports field? Can you provide a copy of the template?

@SelfhostedPro
Copy link
Owner

I think I've resolved it but would like to test your template (if possible) to make sure @yangkghjh.

@SelfhostedPro
Copy link
Owner

I'm building this in the :devel tag. Once this action is done it should be ready for testing:
https://github.com/SelfhostedPro/Yacht/runs/1275659717?check_suite_focus=true

@yangkghjh
Copy link
Author

@SelfhostedPro
Copy link
Owner

Can confirm this template works with the changes in devel. Once you get a chance to test it let me know and I'll merge into master for a hotfix.

@yangkghjh
Copy link
Author

@SelfhostedPro Fixed! Thank you.

@yangkghjh
Copy link
Author

BTW, I think Restart Policy missed option no.

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

2 participants