辣椒在后端烧瓶应用程序中投掷KeyError:' pepper'

发布于 2025-01-22 18:08:15 字数 5130 浏览 0 评论 0原文

我们正在进行一个小型后端项目,而发展后端的伴侣不再与我们合作。我们现在一直坚持这一点,我知道这与与安全有关的有关吗?试图在Heroku上托管后端,我们将获得以下错误日志。

File "/app/cs673backend/__init__.py", line 9, in <module>
2022-04-20T14:27:01.428446+00:00 app[web.1]: from .api import start_api
2022-04-20T14:27:01.428446+00:00 app[web.1]: File "/app/cs673backend/api/__init__.py", line 1, in <module>
2022-04-20T14:27:01.428447+00:00 app[web.1]: from .authentication  import start as start_authen
2022-04-20T14:27:01.428447+00:00 app[web.1]: File "/app/cs673backend/api/authentication.py", line 10, in <module>
2022-04-20T14:27:01.428447+00:00 app[web.1]: PEPPER = environ["PEPPER"].encode("utf-8")
2022-04-20T14:27:01.428447+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/os.py", line 679, in __getitem__
2022-04-20T14:27:01.428447+00:00 app[web.1]: raise KeyError(key) from None
2022-04-20T14:27:01.428448+00:00 app[web.1]: KeyError: 'PEPPER'
2022-04-20T14:27:01.428601+00:00 app[web.1]: [2022-04-20 14:27:01 +0000] [10] [INFO] Worker exiting (pid: 10)
2022-04-20T14:27:01.526847+00:00 app[web.1]: Traceback (most recent call last):
2022-04-20T14:27:01.526854+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 209, in run
2022-04-20T14:27:01.527040+00:00 app[web.1]: self.sleep()
2022-04-20T14:27:01.527042+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 357, in sleep
2022-04-20T14:27:01.527156+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0)
2022-04-20T14:27:01.527157+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-04-20T14:27:01.527239+00:00 app[web.1]: self.reap_workers()
2022-04-20T14:27:01.527240+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-04-20T14:27:01.527354+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-04-20T14:27:01.527399+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-04-20T14:27:01.527400+00:00 app[web.1]:
2022-04-20T14:27:01.527401+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2022-04-20T14:27:01.527401+00:00 app[web.1]:
2022-04-20T14:27:01.527402+00:00 app[web.1]: Traceback (most recent call last):
2022-04-20T14:27:01.527410+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2022-04-20T14:27:01.527463+00:00 app[web.1]: sys.exit(run())
2022-04-20T14:27:01.527471+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
2022-04-20T14:27:01.527535+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2022-04-20T14:27:01.527542+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/base.py", line 231, in run
2022-04-20T14:27:01.527621+00:00 app[web.1]: super().run()
2022-04-20T14:27:01.527622+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/base.py", line 72, in run
2022-04-20T14:27:01.527681+00:00 app[web.1]: Arbiter(self).run()
2022-04-20T14:27:01.527682+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 229, in run
2022-04-20T14:27:01.527757+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2022-04-20T14:27:01.527759+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 342, in halt
2022-04-20T14:27:01.527851+00:00 app[web.1]: self.stop()
2022-04-20T14:27:01.527852+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 393, in stop
2022-04-20T14:27:01.527949+00:00 app[web.1]: time.sleep(0.1)
2022-04-20T14:27:01.527950+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-04-20T14:27:01.528026+00:00 app[web.1]: self.reap_workers()
2022-04-20T14:27:01.528027+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-04-20T14:27:01.528141+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-04-20T14:27:01.528167+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-04-20T14:27:01.691720+00:00 heroku[web.1]: Process exited with status 1
2022-04-20T14:27:01.754717+00:00 heroku[web.1]: State changed from up to crashed
2022-04-20T14:27:27.811162+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=host-py.herokuapp.com request_id=eb24802e-f317-4c41-9f38-8a52371ac736 fwd="117.98.153.124" dyno= connect= service= status=503 bytes= protocol=https
2022-04-20T14:27:28.408186+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=host-py.herokuapp.com request_id=f1532d3b-8c0a-411e-8133-8193e889595a fwd="117.98.153.124" dyno= connect= service= status=503 bytes= protocol=https

We are doing a small backend project and the mate who developed the backend is not working with us anymore. We are stuck with this now, I understand this is related to security related? Trying to host the backend on Heroku and we get the below error log.

File "/app/cs673backend/__init__.py", line 9, in <module>
2022-04-20T14:27:01.428446+00:00 app[web.1]: from .api import start_api
2022-04-20T14:27:01.428446+00:00 app[web.1]: File "/app/cs673backend/api/__init__.py", line 1, in <module>
2022-04-20T14:27:01.428447+00:00 app[web.1]: from .authentication  import start as start_authen
2022-04-20T14:27:01.428447+00:00 app[web.1]: File "/app/cs673backend/api/authentication.py", line 10, in <module>
2022-04-20T14:27:01.428447+00:00 app[web.1]: PEPPER = environ["PEPPER"].encode("utf-8")
2022-04-20T14:27:01.428447+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/os.py", line 679, in __getitem__
2022-04-20T14:27:01.428447+00:00 app[web.1]: raise KeyError(key) from None
2022-04-20T14:27:01.428448+00:00 app[web.1]: KeyError: 'PEPPER'
2022-04-20T14:27:01.428601+00:00 app[web.1]: [2022-04-20 14:27:01 +0000] [10] [INFO] Worker exiting (pid: 10)
2022-04-20T14:27:01.526847+00:00 app[web.1]: Traceback (most recent call last):
2022-04-20T14:27:01.526854+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 209, in run
2022-04-20T14:27:01.527040+00:00 app[web.1]: self.sleep()
2022-04-20T14:27:01.527042+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 357, in sleep
2022-04-20T14:27:01.527156+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0)
2022-04-20T14:27:01.527157+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-04-20T14:27:01.527239+00:00 app[web.1]: self.reap_workers()
2022-04-20T14:27:01.527240+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-04-20T14:27:01.527354+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-04-20T14:27:01.527399+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-04-20T14:27:01.527400+00:00 app[web.1]:
2022-04-20T14:27:01.527401+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2022-04-20T14:27:01.527401+00:00 app[web.1]:
2022-04-20T14:27:01.527402+00:00 app[web.1]: Traceback (most recent call last):
2022-04-20T14:27:01.527410+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2022-04-20T14:27:01.527463+00:00 app[web.1]: sys.exit(run())
2022-04-20T14:27:01.527471+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
2022-04-20T14:27:01.527535+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2022-04-20T14:27:01.527542+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/base.py", line 231, in run
2022-04-20T14:27:01.527621+00:00 app[web.1]: super().run()
2022-04-20T14:27:01.527622+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/app/base.py", line 72, in run
2022-04-20T14:27:01.527681+00:00 app[web.1]: Arbiter(self).run()
2022-04-20T14:27:01.527682+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 229, in run
2022-04-20T14:27:01.527757+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2022-04-20T14:27:01.527759+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 342, in halt
2022-04-20T14:27:01.527851+00:00 app[web.1]: self.stop()
2022-04-20T14:27:01.527852+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 393, in stop
2022-04-20T14:27:01.527949+00:00 app[web.1]: time.sleep(0.1)
2022-04-20T14:27:01.527950+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-04-20T14:27:01.528026+00:00 app[web.1]: self.reap_workers()
2022-04-20T14:27:01.528027+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-04-20T14:27:01.528141+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-04-20T14:27:01.528167+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-04-20T14:27:01.691720+00:00 heroku[web.1]: Process exited with status 1
2022-04-20T14:27:01.754717+00:00 heroku[web.1]: State changed from up to crashed
2022-04-20T14:27:27.811162+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=host-py.herokuapp.com request_id=eb24802e-f317-4c41-9f38-8a52371ac736 fwd="117.98.153.124" dyno= connect= service= status=503 bytes= protocol=https
2022-04-20T14:27:28.408186+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=host-py.herokuapp.com request_id=f1532d3b-8c0a-411e-8133-8193e889595a fwd="117.98.153.124" dyno= connect= service= status=503 bytes= protocol=https

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兔姬 2025-01-29 18:08:15

堆栈跟踪告诉所有:

2022-04-20T14:27:01.428446+00:00 app[web.1]: from .api import start_api
2022-04-20T14:27:01.428446+00:00 app[web.1]: File "/app/cs673backend/api/__init__.py", line 1, in <module>
2022-04-20T14:27:01.428447+00:00 app[web.1]: from .  import start as start_authen
2022-04-20T14:27:01.428447+00:00 app[web.1]: File "/app/cs673backend/api/authentication.py", line 10, in <module>
2022-04-20T14:27:01.428447+00:00 app[web.1]: PEPPER = environ["PEPPER"].encode("utf-8")

在这里,似乎在api的导入时,可能是在处理__ __ INT __。 ,在处理时

PEPPER = environ["PEPPER"].encode("utf-8")

遇到。不幸的是,

2022-04-20T14:27:01.428447+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/os.py", line 679, in __getitem__
2022-04-20T14:27:01.428447+00:00 app[web.1]: raise KeyError(key) from None
2022-04-20T14:27:01.428448+00:00 app[web.1]: KeyError: 'PEPPER'

该环境变量尚未设置。获取该套装(请咨询Heroku文档),然后重试。

The stack trace tells all:

2022-04-20T14:27:01.428446+00:00 app[web.1]: from .api import start_api
2022-04-20T14:27:01.428446+00:00 app[web.1]: File "/app/cs673backend/api/__init__.py", line 1, in <module>
2022-04-20T14:27:01.428447+00:00 app[web.1]: from .  import start as start_authen
2022-04-20T14:27:01.428447+00:00 app[web.1]: File "/app/cs673backend/api/authentication.py", line 10, in <module>
2022-04-20T14:27:01.428447+00:00 app[web.1]: PEPPER = environ["PEPPER"].encode("utf-8")

Here, it appears that on import of api, possibly during processing of __init__.py, there's an import of authentication, and while processing that,

PEPPER = environ["PEPPER"].encode("utf-8")

is encountered. Unfortunately,

2022-04-20T14:27:01.428447+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/os.py", line 679, in __getitem__
2022-04-20T14:27:01.428447+00:00 app[web.1]: raise KeyError(key) from None
2022-04-20T14:27:01.428448+00:00 app[web.1]: KeyError: 'PEPPER'

That environment variable isn't set. Get that set (consult the Heroku docs) and try again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文