langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. It’s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
34.59k stars 4.16k forks source link

LangFlow Store crendential error #2861

Closed LeeJaehyeok0802 closed 3 months ago

LeeJaehyeok0802 commented 4 months ago

Bug Description

python -m langflow run

Welcome to ⛓ Langflow │ │ │ │ │ │ A new version of langflow is available: 1.0.11 │ │ │ │ Run 'pip install langflow -U' to update. │ │ │ │ Collaborate, and contribute at our GitHub Repo 🌟 │ │ │ │ We collect anonymous usage data to improve Langflow. │ │ You can opt-out by setting DO_NOT_TRACK=true in your environment. │ │ │ │ Access http://127.0.0.1:7862 │ ╰───────────────────────────────────────────────────────────────────╯ [07/22/24 07:46:53] ERROR 2024-07-22 07:46:53 - ERROR - store - Failed to decrypt API key: store.py:48 [07/22/24 07:48:25] ERROR 2024-07-22 07:48:25 - ERROR - utils - JWT decoding error: Not enough segments utils.py:133 ERROR 2024-07-22 07:48:25 - ERROR - utils - Not enough segmentsTraceback (most recent call last): utils.py:134 File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/jose/jws.py", line 176, in _load
signing_input, crypto_segment = jwt.rsplit(b".", 1)
| -> <method 'rsplit' of 'bytes' objects>
-> b'UvWog-iSLsDFXxzBSkXHGLWeYBw8UbAK'

                         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 "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/jose/jwt.py", line 142, in decode                                                                                                         
                             payload = jws.verify(token, key, algorithms, verify=verify_signature)                                                                                                                                        
                                       |   |      |      |    |                  -> True                                                                                                                                                  
                                       |   |      |      |    -> ['HS256']                                                                                                                                                                
                                       |   |      |      -> 'U7CzFpP_nBvpupUEoIbHTLUD0Xt1XPJayg9CWFpqdQQ'                                                                                                                                 
                                       |   |      -> 'UvWog-iSLsDFXxzBSkXHGLWeYBw8UbAK'                                                                                                                                                   
                                       |   -> <function verify at 0x7fc64cfc1750>                                                                                                                                                         
                                       -> <module 'jose.jws' from '/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/jose/jws.py'>                                                                                           
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/jose/jws.py", line 70, in verify                                                                                                          
                             header, payload, signing_input, signature = _load(token)                                                                                                                                                     
                                                                         |     -> 'UvWog-iSLsDFXxzBSkXHGLWeYBw8UbAK'                                                                                                                      
                                                                         -> <function _load at 0x7fc64bd1aef0>                                                                                                                            
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/jose/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 "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main                                                                                                                                          
                             return _run_code(code, main_globals, None,                                                                                                                                                                   
                                    |         |     -> {'__name__': '__main__', '__doc__': None, '__package__': 'langflow', '__loader__': <_frozen_importlib_external.SourceFileLoad...                                                   
                                    |         -> <code object <module> at 0x7fc667f87d60, file "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/langflow/__main...                                                         
                                    -> <function _run_code at 0x7fc667f99360>                                                                                                                                                             
                           File "/usr/lib/python3.10/runpy.py", line 86, in _run_code                                                                                                                                                     
                             exec(code, run_globals)                                                                                                                                                                                      
                                  |     -> {'__name__': '__main__', '__doc__': None, '__package__': 'langflow', '__loader__': <_frozen_importlib_external.SourceFileLoad...                                                               
                                  -> <code object <module> at 0x7fc667f87d60, file "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/langflow/__main...                                                                     
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/langflow/__main__.py", line 609, in <module>                                                                                              
                             main()                                                                                                                                                                                                       
                             -> <function main at 0x7fc643c9d120>                                                                                                                                                                         
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/langflow/__main__.py", line 605, in main                                                                                                  
                             app()                                                                                                                                                                                                        
                             -> <typer.main.Typer object at 0x7fc666729930>                                                                                                                                                               
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/typer/main.py", line 309, in __call__                                                                                                     
                             return get_command(self)(*args, **kwargs)                                                                                                                                                                    
                                    |           |      |       -> {}                                                                                                                                                                      
                                    |           |      -> ()                                                                                                                                                                              
                                    |           -> <typer.main.Typer object at 0x7fc666729930>                                                                                                                                            
                                    -> <function get_command at 0x7fc66680dc60>                                                                                                                                                           
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/click/core.py", line 1157, in __call__                                                                                                    
                             return self.main(*args, **kwargs)                                                                                                                                                                            
                                    |    |     |       -> {}                                                                                                                                                                              
                                    |    |     -> ()                                                                                                                                                                                      
                                    |    -> <function TyperGroup.main at 0x7fc66680c280>                                                                                                                                                  
                                    -> <TyperGroup >                                                                                                                                                                                      
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/typer/core.py", line 723, in main                                                                                                         
                             return _main(                                                                                                                                                                                                
                                    -> <function _main at 0x7fc6668075b0>                                                                                                                                                                 
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/typer/core.py", line 193, in _main                                                                                                        
                             rv = self.invoke(ctx)                                                                                                                                                                                        
                                  |    |      -> <click.core.Context object at 0x7fc643c7f640>                                                                                                                                            
                                  |    -> <function MultiCommand.invoke at 0x7fc667df77f0>                                                                                                                                                
                                  -> <TyperGroup >                                                                                                                                                                                        
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/click/core.py", line 1688, in invoke                                                                                                      
                             return _process_result(sub_ctx.command.invoke(sub_ctx))                                                                                                                                                      
                                    |               |       |       |      -> <click.core.Context object at 0x7fc643cdc820>                                                                                                               
                                    |               |       |       -> <function Command.invoke at 0x7fc667df72e0>                                                                                                                        
                                    |               |       -> <TyperCommand run>                                                                                                                                                         
                                    |               -> <click.core.Context object at 0x7fc643cdc820>                                                                                                                                      
                                    -> <function MultiCommand.invoke.<locals>._process_result at 0x7fc643c9caf0>                                                                                                                          
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/click/core.py", line 1434, in invoke                                                                                                      
                             return ctx.invoke(self.callback, **ctx.params)                                                                                                                                                               
                                    |   |      |    |           |   -> {'host': '127.0.0.1', 'workers': 1, 'timeout': 300, 'port': 7860, 'components_path': PosixPath('/home/cns-intern/Jaehyeok/jh_...                                   
                                    |   |      |    |           -> <click.core.Context object at 0x7fc643cdc820>                                                                                                                          
                                    |   |      |    -> <function run at 0x7fc643c9cee0>                                                                                                                                                   
                                    |   |      -> <TyperCommand run>                                                                                                                                                                      
                                    |   -> <function Context.invoke at 0x7fc667df6050>                                                                                                                                                    
                                    -> <click.core.Context object at 0x7fc643cdc820>                                                                                                                                                      
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/click/core.py", line 783, in invoke                                                                                                       
                             return __callback(*args, **kwargs)                                                                                                                                                                           
                                                |       -> {'host': '127.0.0.1', 'workers': 1, 'timeout': 300, 'port': 7860, 'components_path': PosixPath('/home/cns-intern/Jaehyeok/jh_...                                               
                                                -> ()                                                                                                                                                                                     
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/typer/main.py", line 692, in wrapper                                                                                                      
                             return callback(**use_params)                                                                                                                                                                                
                                    |          -> {'host': '127.0.0.1', 'workers': 1, 'timeout': 300, 'port': 7860, 'components_path': PosixPath('/home/cns-intern/Jaehyeok/jh_...                                                        
                                    -> <function run at 0x7fc6440ac4c0>                                                                                                                                                                   
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/langflow/__main__.py", line 194, in run                                                                                                   
                             process = run_on_mac_or_linux(host, port, log_level, options, app)                                                                                                                                           
                                       |                   |     |     |          |        -> <fastapi.applications.FastAPI object at 0x7fc643cdd630>                                                                                     
                                       |                   |     |     |          -> {'bind': '127.0.0.1:7862', 'workers': 1, 'timeout': 300, 'worker_class': 'langflow.server.LangflowUvicornWorker', 'logger_cla...                     
                                       |                   |     |     -> 'critical'                                                                                                                                                      
                                       |                   |     -> 7862                                                                                                                                                                  
                                       |                   -> '127.0.0.1'                                                                                                                                                                 
                                       -> <function run_on_mac_or_linux at 0x7fc6440ae9e0>                                                                                                                                                
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/langflow/__main__.py", line 222, in run_on_mac_or_linux                                                                                   
                             webapp_process.start()                                                                                                                                                                                       
                             |              -> <function BaseProcess.start at 0x7fc666835d80>                                                                                                                                             
                             -> <Process name='Process-1' parent=35539 started>                                                                                                                                                           
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/multiprocess/process.py", line 121, in start                                                                                              
                             self._popen = self._Popen(self)                                                                                                                                                                              
                             |    |        |    |      -> <Process name='Process-1' parent=35539 started>                                                                                                                                 
                             |    |        |    -> <staticmethod(<function Process._Popen at 0x7fc666718f70>)>                                                                                                                            
                             |    |        -> <Process name='Process-1' parent=35539 started>                                                                                                                                             
                             |    -> None                                                                                                                                                                                                 
                             -> <Process name='Process-1' parent=35539 started>                                                                                                                                                           
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/multiprocess/context.py", line 224, in _Popen                                                                                             
                             return _default_context.get_context().Process._Popen(process_obj)                                                                                                                                            
                                    |                |                            -> <Process name='Process-1' parent=35539 started>                                                                                                      
                                    |                -> <function DefaultContext.get_context at 0x7fc666719120>                                                                                                                           
                                    -> <multiprocess.context.DefaultContext object at 0x7fc666a926e0>                                                                                                                                     
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/multiprocess/context.py", line 281, in _Popen                                                                                             
                             return Popen(process_obj)                                                                                                                                                                                    
                                    |     -> <Process name='Process-1' parent=35539 started>                                                                                                                                              
                                    -> <class 'multiprocess.popen_fork.Popen'>                                                                                                                                                            
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/multiprocess/popen_fork.py", line 19, in __init__                                                                                         
                             self._launch(process_obj)                                                                                                                                                                                    
                             |    |       -> <Process name='Process-1' parent=35539 started>                                                                                                                                              
                             |    -> <function Popen._launch at 0x7fc6432760e0>                                                                                                                                                           
                             -> <multiprocess.popen_fork.Popen object at 0x7fc6432e3e20>                                                                                                                                                  
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/multiprocess/popen_fork.py", line 71, in _launch                                                                                          
                             code = process_obj._bootstrap(parent_sentinel=child_r)                                                                                                                                                       
                                    |           |                          -> 6                                                                                                                                                           
                                    |           -> <function BaseProcess._bootstrap at 0x7fc666836680>                                                                                                                                    
                                    -> <Process name='Process-1' parent=35539 started>                                                                                                                                                    
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/multiprocess/process.py", line 314, in _bootstrap                                                                                         
                             self.run()                                                                                                                                                                                                   
                             |    -> <function BaseProcess.run at 0x7fc666835cf0>                                                                                                                                                         
                             -> <Process name='Process-1' parent=35539 started>                                                                                                                                                           
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/multiprocess/process.py", line 108, in run                                                                                                
                             self._target(*self._args, **self._kwargs)                                                                                                                                                                    
                             |    |        |    |        |    -> {}                                                                                                                                                                       
                             |    |        |    |        -> <Process name='Process-1' parent=35539 started>                                                                                                                               
                             |    |        |    -> ('127.0.0.1', 7862, 'critical', {'bind': '127.0.0.1:7862', 'workers': 1, 'timeout': 300, 'worker_class': 'langflow.server.Lan...                                                       
                             |    |        -> <Process name='Process-1' parent=35539 started>                                                                                                                                             
                             |    -> <function run_langflow at 0x7fc643c9d3f0>                                                                                                                                                            
                             -> <Process name='Process-1' parent=35539 started>                                                                                                                                                           
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/langflow/__main__.py", line 444, in run_langflow                                                                                          
                             LangflowApplication(app, options).run()                                                                                                                                                                      
                             |                   |    -> {'bind': '127.0.0.1:7862', 'workers': 1, 'timeout': 300, 'worker_class': 'langflow.server.LangflowUvicornWorker', 'logger_cla...                                                 
                             |                   -> <fastapi.applications.FastAPI object at 0x7fc643cdd630>                                                                                                                               
                             -> <class 'langflow.server.LangflowApplication'>                                                                                                                                                             
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/gunicorn/app/base.py", line 72, in run                                                                                                    
                             Arbiter(self).run()                                                                                                                                                                                          
                             |       -> <langflow.server.LangflowApplication object at 0x7fc666826c80>                                                                                                                                    
                             -> <class 'gunicorn.arbiter.Arbiter'>                                                                                                                                                                        
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/gunicorn/arbiter.py", line 202, in run                                                                                                    
                             self.manage_workers()                                                                                                                                                                                        
                             |    -> <function Arbiter.manage_workers at 0x7fc643134820>                                                                                                                                                  
                             -> <gunicorn.arbiter.Arbiter object at 0x7fc6432e3b20>                                                                                                                                                       
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/gunicorn/arbiter.py", line 571, in manage_workers                                                                                         
                             self.spawn_workers()                                                                                                                                                                                         
                             |    -> <function Arbiter.spawn_workers at 0x7fc643134940>                                                                                                                                                   
                             -> <gunicorn.arbiter.Arbiter object at 0x7fc6432e3b20>                                                                                                                                                       
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/gunicorn/arbiter.py", line 642, in spawn_workers                                                                                          
                             self.spawn_worker()                                                                                                                                                                                          
                             |    -> <function Arbiter.spawn_worker at 0x7fc6431348b0>                                                                                                                                                    
                             -> <gunicorn.arbiter.Arbiter object at 0x7fc6432e3b20>                                                                                                                                                       
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker                                                                                           
                             worker.init_process()                                                                                                                                                                                        
                             |      -> <function UvicornWorker.init_process at 0x7fc65f451240>                                                                                                                                            
                             -> <langflow.server.LangflowUvicornWorker object at 0x7fc6431d4430>                                                                                                                                          
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/uvicorn/workers.py", line 75, in init_process                                                                                             
                             super().init_process()                                                                                                                                                                                       
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/gunicorn/workers/base.py", line 142, in init_process                                                                                      
                             self.run()                                                                                                                                                                                                   
                             |    -> <function UvicornWorker.run at 0x7fc65f451480>                                                                                                                                                       
                             -> <langflow.server.LangflowUvicornWorker object at 0x7fc6431d4430>                                                                                                                                          
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/uvicorn/workers.py", line 107, in run                                                                                                     
                             return asyncio.run(self._serve())                                                                                                                                                                            
                                    |       |   |    -> <function LangflowUvicornWorker._serve at 0x7fc65f4515a0>                                                                                                                         
                                    |       |   -> <langflow.server.LangflowUvicornWorker object at 0x7fc6431d4430>                                                                                                                       
                                    |       -> <function _patch_asyncio.<locals>.run at 0x7fc65f451ab0>                                                                                                                                   
                                    -> <module 'asyncio' from '/usr/lib/python3.10/asyncio/__init__.py'>                                                                                                                                  
                           File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run                                                                                                                                                 
                             return loop.run_until_complete(main)                                                                                                                                                                         
                                    |    |                  -> <coroutine object LangflowUvicornWorker._serve at 0x7fc6431b97e0>                                                                                                          
                                    |    -> <function _patch_loop.<locals>.run_until_complete at 0x7fc65f4f2200>                                                                                                                          
                                    -> <_UnixSelectorEventLoop running=True closed=False debug=False>                                                                                                                                     
                           File "/usr/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete                                                                                                                             
                             self.run_forever()                                                                                                                                                                                           
                             |    -> <function _patch_loop.<locals>.run_forever at 0x7fc65f4f2170>                                                                                                                                        
                             -> <_UnixSelectorEventLoop running=True closed=False debug=False>                                                                                                                                            
                           File "/usr/lib/python3.10/asyncio/base_events.py", line 603, in run_forever                                                                                                                                    
                             self._run_once()                                                                                                                                                                                             
                             |    -> <function _patch_loop.<locals>._run_once at 0x7fc65f4f2290>                                                                                                                                          
                             -> <_UnixSelectorEventLoop running=True closed=False debug=False>                                                                                                                                            
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/nest_asyncio.py", line 133, in _run_once                                                                                                  
                             handle._run()                                                                                                                                                                                                
                             |      -> <function Handle._run at 0x7fc6667a8e50>                                                                                                                                                           
                             -> <Handle Task.__wakeup(<Future finis...7fc616dd2b90>>)>                                                                                                                                                    
                           File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run                                                                                                                                                 
                             self._context.run(self._callback, *self._args)                                                                                                                                                               
                             |    |            |    |           |    -> <member '_args' of 'Handle' objects>                                                                                                                              
                             |    |            |    |           -> <Handle Task.__wakeup(<Future finis...7fc616dd2b90>>)>                                                                                                                 
                             |    |            |    -> <member '_callback' of 'Handle' objects>                                                                                                                                           
                             |    |            -> <Handle Task.__wakeup(<Future finis...7fc616dd2b90>>)>                                                                                                                                  
                             |    -> <member '_context' of 'Handle' objects>                                                                                                                                                              
                             -> <Handle Task.__wakeup(<Future finis...7fc616dd2b90>>)>                                                                                                                                                    
                           File "/usr/lib/python3.10/asyncio/tasks.py", line 315, in __wakeup                                                                                                                                             
                             self.__step()                                                                                                                                                                                                
                             -> <Task pending name='starlette.middleware.base.BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.coro' coro=<BaseHTTPMid...                                                                          
                           File "/usr/lib/python3.10/asyncio/tasks.py", line 232, in __step                                                                                                                                               
                             result = coro.send(None)                                                                                                                                                                                     
                                      |    -> <method 'send' of 'coroutine' objects>                                                                                                                                                      
                                      -> <coroutine object BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.coro at 0x7fc616df1cb0>                                                                                                
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/starlette/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 0x7fc616dc8af0>                                                           
                                   |    |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x7fc616dc9ab0>                                                                          
                                   |    |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7862), 'cl...                                                           
                                   |    -> <starlette.middleware.cors.CORSMiddleware object at 0x7fc65f4e5600>                                                                                                                            
                                   -> <langflow.main.JavaScriptMIMETypeMiddleware object at 0x7fc65f4e55a0>                                                                                                                               
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 93, in __call__                                                                                       
                             await self.simple_response(scope, receive, send, request_headers=headers)                                                                                                                                    
                                   |    |               |      |        |                     -> Headers({'host': '127.0.0.1:7862', 'connection': 'keep-alive', 'content-length': '46', 'sec-ch-ua': '"Not/A)Brand";v="8",                
                         "Ch...                                                                                                                                                                                                           
                                   |    |               |      |        -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at 0x7fc616dc8af0>                                                             
                                   |    |               |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x7fc616dc9ab0>                                                              
                                   |    |               -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7862), 'cl...                                               
                                   |    -> <function CORSMiddleware.simple_response at 0x7fc664cd3a30>                                                                                                                                    
                                   -> <starlette.middleware.cors.CORSMiddleware object at 0x7fc65f4e5600>                                                                                                                                 
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/starlette/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 0x7fc65f4e5600>>, ...                                           
                                   |    |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x7fc616dc9ab0>                                                                          
                                   |    |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7862), 'cl...                                                           
                                   |    -> <starlette.middleware.exceptions.ExceptionMiddleware object at 0x7fc65f4e5780>                                                                                                                 
                                   -> <starlette.middleware.cors.CORSMiddleware object at 0x7fc65f4e5600>                                                                                                                                 
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/starlette/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                             
                         0x7fc65f4e5600>>, ...                                                                                                                                                                                            
                                   |                            |    |    |     |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x7fc616dc9ab0>                                      
                                   |                            |    |    |     -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7862), 'cl...                       
                                   |                            |    |    -> <starlette.requests.Request object at 0x7fc616d373d0>                                                                                                        
                                   |                            |    -> <fastapi.routing.APIRouter object at 0x7fc643cdd9c0>                                                                                                              
                                   |                            -> <starlette.middleware.exceptions.ExceptionMiddleware object at 0x7fc65f4e5780>                                                                                         
                                   -> <function wrap_app_handling_exceptions at 0x7fc664c85480>                                                                                                                                           
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app                                                                                 
                             await app(scope, receive, sender)                                                                                                                                                                            
                                   |   |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x7fc616dca830>                                                                                  
                                   |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x7fc616dc9ab0>                                                                               
                                   |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7862), 'cl...                                                                
                                   -> <fastapi.routing.APIRouter object at 0x7fc643cdd9c0>                                                                                                                                                
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/starlette/routing.py", line 756, in __call__                                                                                              
                             await self.middleware_stack(scope, receive, send)                                                                                                                                                            
                                   |    |                |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x7fc616dca830>                                                                
                                   |    |                |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x7fc616dc9ab0>                                                             
                                   |    |                -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7862), 'cl...                                              
                                   |    -> <bound method Router.app of <fastapi.routing.APIRouter object at 0x7fc643cdd9c0>>                                                                                                              
                                   -> <fastapi.routing.APIRouter object at 0x7fc643cdd9c0>                                                                                                                                                
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/starlette/routing.py", line 776, in app                                                                                                   
                             await route.handle(scope, receive, send)                                                                                                                                                                     
                                   |     |      |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x7fc616dca830>                                                                         
                                   |     |      |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x7fc616dc9ab0>                                                                      
                                   |     |      -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7862), 'cl...                                                       
                                   |     -> <function Route.handle at 0x7fc664c86c20>                                                                                                                                                     
                                   -> APIRoute(path='/api/v1/api_key/store', name='save_store_api_key', methods=['POST'])                                                                                                                 
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/starlette/routing.py", line 297, in handle                                                                                                
                             await self.app(scope, receive, send)                                                                                                                                                                         
                                   |    |   |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x7fc616dca830>                                                                             
                                   |    |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x7fc616dc9ab0>                                                                          
                                   |    |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7862), 'cl...                                                           
                                   |    -> <function request_response.<locals>.app at 0x7fc643b47910>                                                                                                                                     
                                   -> APIRoute(path='/api/v1/api_key/store', name='save_store_api_key', methods=['POST'])                                                                                                                 
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/starlette/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 0x7fc616dca830>                                           
                                   |                            |    |        |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x7fc616dc9ab0>                                        
                                   |                            |    |        -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7862), 'cl...                         
                                   |                            |    -> <starlette.requests.Request object at 0x7fc616d34a60>                                                                                                             
                                   |                            -> <function request_response.<locals>.app.<locals>.app at 0x7fc616dc9c60>                                                                                                
                                   -> <function wrap_app_handling_exceptions at 0x7fc664c85480>                                                                                                                                           
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app                                                                                 
                             await app(scope, receive, sender)                                                                                                                                                                            
                                   |   |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x7fc616dcb910>                                                                                  
                                   |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x7fc616dc9ab0>                                                                               
                                   |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1', 7862), 'cl...                                                                
                                   -> <function request_response.<locals>.app.<locals>.app at 0x7fc616dc9c60>                                                                                                                             
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/starlette/routing.py", line 72, in app                                                                                                    
                             response = await func(request)                                                                                                                                                                               
                                              |    -> <starlette.requests.Request object at 0x7fc616d34a60>                                                                                                                               
                                              -> <function get_request_handler.<locals>.app at 0x7fc643b46dd0>                                                                                                                            
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/fastapi/routing.py", line 269, in app                                                                                                     
                             solved_result = await solve_dependencies(                                                                                                                                                                    
                                                   -> <function solve_dependencies at 0x7fc664c6ecb0>                                                                                                                                     
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 572, in solve_dependencies                                                                           
                             solved_result = await solve_dependencies(                                                                                                                                                                    
                                                   -> <function solve_dependencies at 0x7fc664c6ecb0>                                                                                                                                     
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 600, in solve_dependencies                                                                           
                             solved = await call(**sub_values)                                                                                                                                                                            
                                            |      -> {'token': 'UvWog-iSLsDFXxzBSkXHGLWeYBw8UbAK', 'query_param': None, 'header_param': None, 'db': <sqlmodel.orm.session.Session ...                                                    
                                            -> <function get_current_user at 0x7fc64bd1bbe0>                                                                                                                                              
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/langflow/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 0x7fc616dd2b90>                                                                                                       
                                          |                       -> 'UvWog-iSLsDFXxzBSkXHGLWeYBw8UbAK'                                                                                                                                   
                                          -> <function get_current_user_by_jwt at 0x7fc64bd1bc70>                                                                                                                                         
                         > File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/langflow/services/auth/utils.py", line 112, in get_current_user_by_jwt                                                                    
                             payload = jwt.decode(token, secret_key, algorithms=)                                                                                                                                                         
                                       |   |      |      |                       |                |             -> 'HS256'                                                                                                                
                                       |   |      |      |                       |                -> AuthSettings(CONFIG_DIR='/home/cns-intern/.cache/langflow', SECRET_KEY=SecretStr('**********'), ALGORITHM='HS256',                   
                         ACCESS_TOK...                                                                                                                                                                                                    
                                       |   |      |      |                       -> <langflow.services.settings.service.SettingsService object at 0x7fc643cdd300>                                                                         
                                       |   |      |      -> 'U7CzFpP_nBvpupUEoIbHTLUD0Xt1XPJayg9CWFpqdQQ'                                                                                                                                 
                                       |   |      -> 'UvWog-iSLsDFXxzBSkXHGLWeYBw8UbAK'                                                                                                                                                   
                                       |   -> <function decode at 0x7fc64bd1b130>                                                                                                                                                         
                                       -> <module 'jose.jwt' from '/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/jose/jwt.py'>                                                                                           
                           File "/home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/jose/jwt.py", line 144, in decode                                                                                                         
                             raise JWTError(e)                                                                                                                                                                                            
                                   -> <class 'jose.exceptions.JWTError'>                                                                                                                                                                  

                         jose.exceptions.JWTError: Not enough segments                                                                                                                                                                    

                         ╭─────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────────────╮             
                         │ /home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/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) ────────────────────────────────────────────────────────────────────────────────╮             
                         │ /home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/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_signature)                                                                                                              │             
                         │   143 │   except JWSError as e:                                                                                                                                                                  │             
                         │   144 │   │   raise JWTError(e)                                                                                                                                                                  │             
                         │   145                                                                                                                                                                                            │             
                         │                                                                                                                                                                                                  │             
                         │ /home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/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, algorithms)                                                                                                               │             
                         │                                                                                                                                                                                                  │             
                         │ /home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/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) ────────────────────────────────────────────────────────────────────────────────╮             
                         │ /home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/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):                                                                                                                                            │             
                         │                                                                                                                                                                                                  │             
                         │ /home/cns-intern/Jaehyeok/jh_venv/lib/python3.10/site-packages/jose/jwt.py:144 in decode                                                                                                         │             
                         │                                                                                                                                                                                                  │             
                         │   141 │   try:                                                                                                                                                                                   │             
                         │   142 │   │   payload = jws.verify(token, key, algorithms, verify=verify_signature)                                                                                                              │             
                         │   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

And I tried to register the Store API Key within this open LangFlow webpage. However, an error of 'API key save error. Could not validate credentials' occurred.

Reproduction

python -m langflow run

Expected behavior

I hope Store API Key will be approved.

Who can help?

No response

Operating System

Ubuntu Linux 22.04

Langflow Version

1.0.11

Python Version

3.10

dosubot[bot] commented 4 months ago

@LeeJaehyeok0802 Hello there! I'm a bot designed to help you solve bugs, answer questions, and become a contributor. I'm here to assist you while you wait for a human maintainer.

To resolve the issues with LangFlow failing to decrypt the API key and encountering JWT decoding errors, follow these steps:

  1. Check Encryption and Decryption Utilities: Ensure that the encrypt_api_key and decrypt_api_key functions in auth_utils are correctly implemented and configured. The decrypt_api_key function should be able to successfully decrypt the stored API key using the correct settings.

  2. Verify JWT Token Structure: The error "Not enough segments" indicates that the JWT token might be malformed. Ensure that the JWT tokens are correctly generated with the required segments (header, payload, and signature).

  3. Review the get_settings_service Configuration: Make sure that the SECRET_KEY and ALGORITHM settings are correctly configured in your environment. These settings are crucial for both encryption/decryption and JWT token management.

  4. Check the get_current_active_user Function: This function ensures that the user is active before proceeding with API key registration and JWT decoding. Verify that it is correctly implemented and that the user is indeed active.

  5. Error Handling and Logging: Review the error messages and stack traces provided by the HTTPException in the store.py and utils.py files. These messages can provide insights into what might be going wrong.

Here are the relevant code snippets for reference:

Encryption and Decryption:

def encrypt_api_key(api_key: str, settings_service=Depends(get_settings_service)):
    fernet = get_fernet(settings_service)
    encrypted_key = fernet.encrypt(api_key.encode())
    return encrypted_key.decode()

def decrypt_api_key(encrypted_api_key: str, settings_service=Depends(get_settings_service)):
    fernet = get_fernet(settings_service)
    encoded_bytes = encrypted_api_key.encode() if isinstance(encrypted_api_key, str) else encrypted_api_key
    decrypted_key = fernet.decrypt(encoded_bytes).decode()
    return decrypted_key

JWT Token Generation:

def create_token(data: dict, expires_delta: timedelta):
    settings_service = get_settings_service()
    to_encode = data.copy()
    expire = datetime.now(timezone.utc) + expires_delta
    to_encode["exp"] = expire
    return jwt.encode(
        to_encode,
        settings_service.auth_settings.SECRET_KEY.get_secret_value(),
        algorithm=settings_service.auth_settings.ALGORITHM,
    )

Error Handling in store.py:

def get_user_store_api_key(
    user: User = Depends(auth_utils.get_current_active_user),
    settings_service=Depends(get_settings_service),
):
    if not user.store_api_key:
        raise HTTPException(status_code=400, detail="You must have a store API key set.")
    try:
        decrypted = auth_utils.decrypt_api_key(user.store_api_key, settings_service)
        return decrypted
    except Exception as e:
        raise HTTPException(status_code=500, detail="Failed to decrypt API key. Please set a new one.") from e

By ensuring that these components are correctly implemented and configured, you should be able to resolve the issues with API key registration and JWT decoding in LangFlow [1][2][3].

To continue talking to Dosu, mention @dosu.

carlosrcoelho commented 3 months ago

Issue duplicate, please refer to this: https://github.com/langflow-ai/langflow/issues/2791