Closed suggsadc closed 4 weeks ago
To resolve the "Fernet key must be 32 url-safe base64-encoded bytes" error when saving the Langflow Store Key in Langflow Version 1.0.5 on Windows 10, you need to ensure that the Fernet key is properly padded to be 32 url-safe base64-encoded bytes. Here is a function to add the necessary padding to the key:
def add_padding(s):
# Calculate the number of padding characters needed
padding_needed = 4 - len(s) % 4
return s + "=" * padding_needed
def get_fernet(settings_service=Depends(get_settings_service)):
SECRET_KEY = settings_service.auth_settings.SECRET_KEY.get_secret_value()
# It's important that your secret key is 32 url-safe base64-encoded bytes
padded_secret_key = add_padding(SECRET_KEY)
fernet = Fernet(padded_secret_key)
return fernet
Ensure that your SECRET_KEY
is properly padded using the add_padding
function before creating the Fernet key. This should resolve the error [1][2][3].
To continue talking to Dosu, mention @dosu.
Hello, How are you copying the API Key? It seems like you are copying the hidden characters, not the actual api key.
If you can send a video of you copying the API Key, pasting it into a notepad and then pasting it into the API Key field, I would be grateful
@suggsadc I would also suggest installing a newer version of langflow. 1.0.11 is the latest version.
@suggsadc I was not able to reproduce the error on 1.0.5 nor the current version. As Lucas mentioned, I would suggest rechecking the API key and ensuring no extra characters are being pasted by accident.
thank you both for keeping up with this ticket... screen vid of me going through the process as i understand it can be found here.
Langflow 1.0.11 does give a different error from before
[07/22/24 12:15:51] ERROR 2024-07-22 12:15:51 - ERROR - utils - JWT decoding error: Not enough utils.py:133 segments ERROR 2024-07-22 12:15:51 - ERROR - utils - Not enough segmentsTraceback (most utils.py:134 recent call last):
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\jos
e\jws.py", line 176, in _load
signing_input, crypto_segment = jwt.rsplit(b".", 1)
| -> <method 'rsplit' of 'bytes'
objects>
-> b'XcSN5CpN6YyNFpUbQznumPXENxtnnZRv'
ValueError: not enough values to unpack (expected 2, got 1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\jos
e\jwt.py", line 142, in decode
payload = jws.verify(token, key, algorithms, verify=verify_signature)
| | | | | -> True
| | | | -> ['HS256']
| | | -> 'R-DzCwki7-fCIIHe1rUxvDqfRdyLQi0x'
| | -> 'XcSN5CpN6YyNFpUbQznumPXENxtnnZRv'
| -> <function verify at 0x000001E8B9B73F60>
-> <module 'jose.jws' from
'C:\\Users\\HPZWS1\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-pac
kages\\jose\\jws.py'>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\jos
e\jws.py", line 70, in verify
header, payload, signing_input, signature = _load(token)
| ->
'XcSN5CpN6YyNFpUbQznumPXENxtnnZRv'
-> <function _load at
0x000001E8B9CE36A0>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\jos
e\jws.py", line 180, in _load
raise JWSError("Not enough segments")
-> <class 'jose.exceptions.JWSError'>
jose.exceptions.JWSError: Not enough segments
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\lan
gflow\__main__.py", line 609, in <module>
main()
-> <function main at 0x000001E8EA8DCFE0>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\lan
gflow\__main__.py", line 605, in main
app()
-> <typer.main.Typer object at 0x000001E8E9CFD790>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\typ
er\main.py", line 309, in __call__
return get_command(self)(*args, **kwargs)
| | | -> {}
| | -> ()
| -> <typer.main.Typer object at 0x000001E8E9CFD790>
-> <function get_command at 0x000001E8B478DEE0>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\cli
ck\core.py", line 1157, in __call__
return self.main(*args, **kwargs)
| | | -> {}
| | -> ()
| -> <function TyperGroup.main at 0x000001E8B477AAC0>
-> <TyperGroup >
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\typ
er\core.py", line 723, in main
return _main(
-> <function _main at 0x000001E8B4779C60>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\typ
er\core.py", line 193, in _main
rv = self.invoke(ctx)
| | -> <click.core.Context object at 0x000001E8EA490190>
| -> <function MultiCommand.invoke at 0x000001E8B2AD6CA0>
-> <TyperGroup >
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\cli
ck\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
| | | | -> <click.core.Context
object at 0x000001E8EA47A390>
| | | -> <function Command.invoke at
0x000001E8B2AD6660>
| | -> <TyperCommand run>
| -> <click.core.Context object at
0x000001E8EA47A390>
-> <function MultiCommand.invoke.<locals>._process_result at
0x000001E8EA877060>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\cli
ck\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
| | | | | -> {'host': '192.168.1.14',
'env_file': 'C:\\Users\\HPZWS1\\Code\\langflow\\.env', 'workers': 1,
'timeout': 300, 'port': 7860, '...
| | | | -> <click.core.Context object at
0x000001E8EA47A390>
| | | -> <function run at 0x000001E8EA8DD120>
| | -> <TyperCommand run>
| -> <function Context.invoke at 0x000001E8B2AD4FE0>
-> <click.core.Context object at 0x000001E8EA47A390>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\cli
ck\core.py", line 783, in invoke
return __callback(*args, **kwargs)
| -> {'host': '192.168.1.14', 'env_file':
'C:\\Users\\HPZWS1\\Code\\langflow\\.env', 'workers': 1, 'timeout': 300,
'port': 7860, '...
-> ()
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\typ
er\main.py", line 692, in wrapper
return callback(**use_params)
| -> {'host': '192.168.1.14', 'workers': 1, 'timeout':
300, 'port': 7860, 'components_path': WindowsPath('C:/Users/HPZWS1/AppData/...
-> <function run at 0x000001E8EA8DC360>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\lan
gflow\__main__.py", line 191, in run
process = run_on_windows(host, port, log_level, options, app)
| | | | | ->
<fastapi.applications.FastAPI object at 0x000001E8EA83D350>
| | | | -> {'bind':
'192.168.1.14:7860', 'workers': 1, 'timeout': 300}
| | | -> 'critical'
| | -> 7860
| -> '192.168.1.14'
-> <function run_on_windows at 0x000001E8EA8DC4A0>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\lan
gflow\__main__.py", line 234, in run_on_windows
run_langflow(host, port, log_level, options, app)
| | | | | ->
<fastapi.applications.FastAPI object at 0x000001E8EA83D350>
| | | | -> {'bind': '192.168.1.14:7860',
'workers': 1, 'timeout': 300}
| | | -> 'critical'
| | -> 7860
| -> '192.168.1.14'
-> <function run_langflow at 0x000001E8EA8DCC20>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\lan
gflow\__main__.py", line 434, in run_langflow
uvicorn.run(
| -> <function run at 0x000001E8EC36CAE0>
-> <module 'uvicorn' from
'C:\\Users\\HPZWS1\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-pac
kages\\uvicorn\\__init__...
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\uvi
corn\main.py", line 577, in run
server.run()
| -> <function Server.run at 0x000001E8EC36CCC0>
-> <uvicorn.server.Server object at 0x000001E8EA4EA350>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\uvi
corn\server.py", line 65, in run
return asyncio.run(self.serve(sockets=sockets))
| | | | -> None
| | | -> <function Server.serve at 0x000001E8EC36CD60>
| | -> <uvicorn.server.Server object at 0x000001E8EA4EA350>
| -> <function _patch_asyncio.<locals>.run at
0x000001E8EC45DDA0>
-> <module 'asyncio' from
'C:\\Users\\HPZWS1\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\asyncio\
\__init__.py'>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.p
y", line 190, in run
return runner.run(main)
| | -> <coroutine object Server.serve at 0x000001E8EA990220>
| -> <function Runner.run at 0x000001E8B36F5580>
-> <asyncio.runners.Runner object at 0x000001E8EC3166D0>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.p
y", line 118, in run
return self._loop.run_until_complete(task)
| | | -> <Task pending name='Task-1'
coro=<Server.serve() running at
C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-...
| | -> <function _patch_loop.<locals>.run_until_complete at
0x000001E8EC45E160>
| -> <ProactorEventLoop running=True closed=False debug=False>
-> <asyncio.runners.Runner object at 0x000001E8EC3166D0>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_even
ts.py", line 641, in run_until_complete
self.run_forever()
| -> <function _patch_loop.<locals>.run_forever at 0x000001E8EC45E0C0>
-> <ProactorEventLoop running=True closed=False debug=False>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_e
vents.py", line 321, in run_forever
super().run_forever()
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_even
ts.py", line 608, in run_forever
self._run_once()
| -> <function _patch_loop.<locals>._run_once at 0x000001E8EC45E200>
-> <ProactorEventLoop running=True closed=False debug=False>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\nes
t_asyncio.py", line 133, in _run_once
handle._run()
| -> <function Handle._run at 0x000001E8B3684EA0>
-> <Handle Task.__wakeup(<Future finis...01E8F8FE9450>>)>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\asyncio\events.py
", line 84, in _run
self._context.run(self._callback, *self._args)
| | | | | -> <member '_args' of 'Handle'
objects>
| | | | -> <Handle Task.__wakeup(<Future
finis...01E8F8FE9450>>)>
| | | -> <member '_callback' of 'Handle' objects>
| | -> <Handle Task.__wakeup(<Future
finis...01E8F8FE9450>>)>
| -> <member '_context' of 'Handle' objects>
-> <Handle Task.__wakeup(<Future finis...01E8F8FE9450>>)>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py"
, line 360, in __wakeup
self.__step()
-> <Task pending
name='starlette.middleware.base.BaseHTTPMiddleware.__call__.<locals>.call_next
.<locals>.coro' coro=<BaseHTTPMid...
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py"
, line 277, in __step
result = coro.send(None)
| -> <method 'send' of 'coroutine' objects>
-> <coroutine object
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.coro at
0x000001E8EE9C7EF0>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\sta
rlette\middleware\base.py", line 151, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
| | | | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at
0x000001E8F9F70900>
| | | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect
at 0x000001E8F9F707C0>
| | -> {'type': 'http', 'asgi': {'version': '3.0',
'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('192.168.1.14',
7860), ...
| -> <starlette.middleware.cors.CORSMiddleware object at
0x000001E8EA401750>
-> <langflow.main.JavaScriptMIMETypeMiddleware object at
0x000001E8EC1D4510>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\sta
rlette\middleware\cors.py", line 93, in __call__
await self.simple_response(scope, receive, send, request_headers=headers)
| | | | | ->
Headers({'host': '192.168.1.14:7860', 'connection': 'keep-alive',
'content-length': '46', 'accept': 'application/json, text/p...
| | | | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at
0x000001E8F9F70900>
| | | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect
at 0x000001E8F9F707C0>
| | -> {'type': 'http', 'asgi': {'version': '3.0',
'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('192.168.1.14',
7860), ...
| -> <function CORSMiddleware.simple_response at
0x000001E8B6B736A0>
-> <starlette.middleware.cors.CORSMiddleware object at
0x000001E8EA401750>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\sta
rlette\middleware\cors.py", line 148, in simple_response
await self.app(scope, receive, send)
| | | | -> functools.partial(<bound method
CORSMiddleware.send of <starlette.middleware.cors.CORSMiddleware object at
0x000001E8EA401750...
| | | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect
at 0x000001E8F9F707C0>
| | -> {'type': 'http', 'asgi': {'version': '3.0',
'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('192.168.1.14',
7860), ...
| -> <starlette.middleware.exceptions.ExceptionMiddleware object
at 0x000001E8EC464050>
-> <starlette.middleware.cors.CORSMiddleware object at
0x000001E8EA401750>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\sta
rlette\middleware\exceptions.py", line 65, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
| | | | | | ->
functools.partial(<bound method CORSMiddleware.send of
<starlette.middleware.cors.CORSMiddleware object at 0x000001E8EA401750...
| | | | | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect
at 0x000001E8F9F707C0>
| | | | -> {'type': 'http',
'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1',
'server': ('192.168.1.14', 7860), ...
| | | ->
<starlette.requests.Request object at 0x000001E8FB721D90>
| | -> <fastapi.routing.APIRouter
object at 0x000001E8EA493A10>
| ->
<starlette.middleware.exceptions.ExceptionMiddleware object at
0x000001E8EC464050>
-> <function wrap_app_handling_exceptions at 0x000001E8B6B28D60>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\sta
rlette\_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
| | | -> <function
wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at
0x000001E8F9D80540>
| | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect
at 0x000001E8F9F707C0>
| -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version':
'2.4'}, 'http_version': '1.1', 'server': ('192.168.1.14', 7860), ...
-> <fastapi.routing.APIRouter object at 0x000001E8EA493A10>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\sta
rlette\routing.py", line 756, in __call__
await self.middleware_stack(scope, receive, send)
| | | | -> <function
wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at
0x000001E8F9D80540>
| | | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect
at 0x000001E8F9F707C0>
| | -> {'type': 'http', 'asgi': {'version': '3.0',
'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('192.168.1.14',
7860), ...
| -> <bound method Router.app of <fastapi.routing.APIRouter
object at 0x000001E8EA493A10>>
-> <fastapi.routing.APIRouter object at 0x000001E8EA493A10>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\sta
rlette\routing.py", line 776, in app
await route.handle(scope, receive, send)
| | | | -> <function
wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at
0x000001E8F9D80540>
| | | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect
at 0x000001E8F9F707C0>
| | -> {'type': 'http', 'asgi': {'version': '3.0',
'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('192.168.1.14',
7860), ...
| -> <function Route.handle at 0x000001E8B6B2A480>
-> APIRoute(path='/api/v1/api_key/store', name='save_store_api_key',
methods=['POST'])
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\sta
rlette\routing.py", line 297, in handle
await self.app(scope, receive, send)
| | | | -> <function
wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at
0x000001E8F9D80540>
| | | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect
at 0x000001E8F9F707C0>
| | -> {'type': 'http', 'asgi': {'version': '3.0',
'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('192.168.1.14',
7860), ...
| -> <function request_response.<locals>.app at
0x000001E8EC2107C0>
-> APIRoute(path='/api/v1/api_key/store', name='save_store_api_key',
methods=['POST'])
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\sta
rlette\routing.py", line 77, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
| | | | | ->
<function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at
0x000001E8F9D80540>
| | | | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect
at 0x000001E8F9F707C0>
| | | -> {'type': 'http',
'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1',
'server': ('192.168.1.14', 7860), ...
| | -> <starlette.requests.Request
object at 0x000001E8FB721E90>
| -> <function
request_response.<locals>.app.<locals>.app at 0x000001E8F9D81EE0>
-> <function wrap_app_handling_exceptions at 0x000001E8B6B28D60>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\sta
rlette\_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
| | | -> <function
wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at
0x000001E8F9D81D00>
| | -> <function
BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect
at 0x000001E8F9F707C0>
| -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version':
'2.4'}, 'http_version': '1.1', 'server': ('192.168.1.14', 7860), ...
-> <function request_response.<locals>.app.<locals>.app at
0x000001E8F9D81EE0>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\sta
rlette\routing.py", line 72, in app
response = await func(request)
| -> <starlette.requests.Request object at
0x000001E8FB721E90>
-> <function get_request_handler.<locals>.app at
0x000001E8EC210220>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\fas
tapi\routing.py", line 269, in app
solved_result = await solve_dependencies(
-> <function solve_dependencies at
0x000001E8B6B06B60>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\fas
tapi\dependencies\utils.py", line 572, in solve_dependencies
solved_result = await solve_dependencies(
-> <function solve_dependencies at
0x000001E8B6B06B60>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\fas
tapi\dependencies\utils.py", line 600, in solve_dependencies
solved = await call(**sub_values)
| -> {'token': 'XcSN5CpN6YyNFpUbQznumPXENxtnnZRv',
'query_param': None, 'header_param': None, 'db': <sqlmodel.orm.session.Session
...
-> <function get_current_user at 0x000001E8B9CF00E0>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\lan
gflow\services\auth\utils.py", line 78, in get_current_user
return await get_current_user_by_jwt(token, db)
| | ->
<sqlmodel.orm.session.Session object at 0x000001E8F8FE9450>
| -> 'XcSN5CpN6YyNFpUbQznumPXENxtnnZRv'
-> <function get_current_user_by_jwt at 0x000001E8B9CF04A0>
> File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\lan
gflow\services\auth\utils.py", line 112, in get_current_user_by_jwt
payload = jwt.decode(token, secret_key, algorithms=)
| | | | | |
-> 'HS256'
| | | | | ->
AuthSettings(CONFIG_DIR='C:\\Users\\HPZWS1\\AppData\\Local\\langflow\\langflow
\\Cache', SECRET_KEY=SecretStr('**********'), A...
| | | | ->
<langflow.services.settings.service.SettingsService object at
0x000001E8BA416750>
| | | -> 'R-DzCwki7-fCIIHe1rUxvDqfRdyLQi0x'
| | -> 'XcSN5CpN6YyNFpUbQznumPXENxtnnZRv'
| -> <function decode at 0x000001E8B9B73E20>
-> <module 'jose.jwt' from
'C:\\Users\\HPZWS1\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-pac
kages\\jose\\jwt.py'>
File
"C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\jos
e\jwt.py", line 144, in decode
raise JWTError(e)
-> <class 'jose.exceptions.JWTError'>
jose.exceptions.JWTError: Not enough segments
╭──────────────────── Traceback (most recent call last) ─────────────────────╮
│ C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\ │
│ jose\jws.py:176 in _load │
│ │
│ 173 │ if isinstance(jwt, str): │
│ 174 │ │ jwt = jwt.encode("utf-8") │
│ 175 │ try: │
│ ❱ 176 │ │ signing_input, crypto_segment = jwt.rsplit(b".", 1) │
│ 177 │ │ header_segment, claims_segment = signing_input.split(b".", 1 │
│ 178 │ │ header_data = base64url_decode(header_segment) │
│ 179 │ except ValueError: │
╰────────────────────────────────────────────────────────────────────────────╯
ValueError: not enough values to unpack (expected 2, got 1)
During handling of the above exception, another exception occurred:
╭──────────────────── Traceback (most recent call last) ─────────────────────╮
│ C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\ │
│ jose\jwt.py:142 in decode │
│ │
│ 139 │ verify_signature = defaults.get("verify_signature", True) │
│ 140 │ │
│ 141 │ try: │
│ ❱ 142 │ │ payload = jws.verify(token, key, algorithms, verify=verify_s │
│ 143 │ except JWSError as e: │
│ 144 │ │ raise JWTError(e) │
│ 145 │
│ │
│ C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\ │
│ jose\jws.py:70 in verify │
│ │
│ 67 │ │
│ 68 │ """ │
│ 69 │ │
│ ❱ 70 │ header, payload, signing_input, signature = _load(token) │
│ 71 │ │
│ 72 │ if verify: │
│ 73 │ │ _verify_signature(signing_input, header, signature, key, alg │
│ │
│ C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\ │
│ jose\jws.py:180 in _load │
│ │
│ 177 │ │ header_segment, claims_segment = signing_input.split(b".", 1 │
│ 178 │ │ header_data = base64url_decode(header_segment) │
│ 179 │ except ValueError: │
│ ❱ 180 │ │ raise JWSError("Not enough segments") │
│ 181 │ except (TypeError, binascii.Error): │
│ 182 │ │ raise JWSError("Invalid header padding") │
│ 183 │
╰────────────────────────────────────────────────────────────────────────────╯
JWSError: Not enough segments
During handling of the above exception, another exception occurred:
╭──────────────────── Traceback (most recent call last) ─────────────────────╮
│ C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\ │
│ langflow\services\auth\utils.py:112 in get_current_user_by_jwt │
│ │
│ 109 │ try: │
│ 110 │ │ with warnings.catch_warnings(): │
│ 111 │ │ │ warnings.simplefilter("ignore") │
│ ❱ 112 │ │ │ payload = jwt.decode(token, secret_key, │
│ algorithms=[settings_service.auth_settings.ALGORITHM]) │
│ 113 │ │ user_id: UUID = payload.get("sub") # type: ignore │
│ 114 │ │ token_type: str = payload.get("type") # type: ignore │
│ 115 │ │ if expires := payload.get("exp", None): │
│ │
│ C:\Users\HPZWS1\AppData\Local\Programs\Python\Python311\Lib\site-packages\ │
│ jose\jwt.py:144 in decode │
│ │
│ 141 │ try: │
│ 142 │ │ payload = jws.verify(token, key, algorithms, verify=verify_s │
│ 143 │ except JWSError as e: │
│ ❱ 144 │ │ raise JWTError(e) │
│ 145 │ │
│ 146 │ # Needed for at_hash verification │
│ 147 │ algorithm = jws.get_unverified_header(token)["alg"] │
╰────────────────────────────────────────────────────────────────────────────╯
JWTError: Not enough segments
Hi @suggsadc, the secret key stored in the .cache folder is generated randomly during Langflow's startup and saved.
This key is a URL-safe base64-encoded 32-byte used by the Fernet library for encryption and decryption, so it should not be updated unless the Langflow folder in .cache is deleted.
The key you enter in the frontend application will be saved in the database under your user account, encrypted with the secret key mentioned above.
To work around this error, delete the secret_key file in the .cache folder and run Langflow again to generate a new key. Additionally, the frontend was losing this key stored in a cookie. To address this, we will store the key on the backend instead.
hi @jordanrfrazier @suggsadc,
this #2960 should fix our problem with the store api-keys. any further problems please contact us.
thanks you
Describe the bug Attempts to use a Langflow Store Key fails with error "Fernet key must be 32 url-safe base64-encoded bytes."
Langflow Version
To Reproduce Steps to reproduce the behavior: