Skip to content

Conversation

aayush72969
Copy link

@aayush72969 aayush72969 commented Jul 25, 2025

Description

(insert summary)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

@aayush72969
Copy link
Author

I think this is the better code to have.

@uruwhy
Copy link
Contributor

uruwhy commented Aug 19, 2025

Unfortunately much of the Caldera internal code requires the config fields to contain the periods, like app.contact.http rather than using the nested dictionaries. This is because the get_config function in base_world.py does not handle the nested dictionaries but rather expects the intact dotted notation. You would have to rewrite a lot of the code to support this config file format.

I tried running the Caldera server from your branch and came across a lot of errors because of this:

ERROR    Task exception was never retrieved                                                        base_events.py:1821
                             future: <Task finished name='Task-5' coro=<Contact.start() done, defined at                                  
                             /home/cauro/prs/caldera/app/contacts/contact_html.py:16> exception=TypeError("argument of                    
                             type 'NoneType' is not iterable")>                                                                           
                             ╭────────────────────────── Traceback (most recent call last) ──────────────────────────╮                    
                             │ /home/cauro/prs/caldera/app/contacts/contact_html.py:17 in start                      │                    
                             │                                                                                       │                    
                             │   14 │   │   self.contact_svc = services.get('contact_svc')                           │                    
                             │   15 │                                                                                │                    
                             │   16 │   async def start(self):                                                       │                    
                             │ ❱ 17 │   │   self.app_svc.application.router.add_route('*',                           │                    
                             │      self.get_config('app.contact.html'), self._accept_beacon)                        │                    
                             │   18 │                                                                                │                    
                             │   19 │   @template('weather.html')                                                    │                    
                             │   20 │   async def _accept_beacon(self, request):                                     │                    
                             │                                                                                       │                    
                             │ /home/cauro/prs/caldera/.venv/lib/python3.12/site-packages/aiohttp/web_urldispatcher. │                    
                             │ py:1177 in add_route                                                                  │                    
                             │                                                                                       │                    
                             │   1174 │   │   name: Optional[str] = None,                                            │                    
                             │   1175 │   │   expect_handler: Optional[_ExpectHandler] = None,                       │                    
                             │   1176 │   ) -> AbstractRoute:                                                        │                    
                             │ ❱ 1177 │   │   resource = self.add_resource(path, name=name)                          │                    
                             │   1178 │   │   return resource.add_route(method, handler, expect_handler=expect_handl │                    
                             │   1179 │                                                                              │                    
                             │   1180 │   def add_static(                                                            │                    
                             │                                                                                       │                    
                             │ /home/cauro/prs/caldera/.venv/lib/python3.12/site-packages/aiohttp/web_urldispatcher. │                    
                             │ py:1160 in add_resource                                                               │                    
                             │                                                                                       │                    
                             │   1157 │   │   │   resource = self._resources[-1]                                     │                    
                             │   1158 │   │   │   if resource.name == name and resource.raw_match(path):             │                    
                             │   1159 │   │   │   │   return cast(Resource, resource)                                │                    
                             │ ❱ 1160 │   │   if not ("{" in path or "}" in path or ROUTE_RE.search(path)):          │                    
                             │   1161 │   │   │   resource = PlainResource(path, name=name)                          │                    
                             │   1162 │   │   │   self.register_resource(resource)                                   │                    
                             │   1163 │   │   │   return resource                                                    │                    
                             ╰───────────────────────────────────────────────────────────────────────────────────────╯                    
                             TypeError: argument of type 'NoneType' is not iterable                                                       
                    ERROR    Task exception was never retrieved                                                        base_events.py:1821
                             future: <Task finished name='Task-6' coro=<Contact.start() done, defined at                                  
                             /home/cauro/prs/caldera/app/contacts/contact_udp.py:18>                                                      
                             exception=AttributeError("'NoneType' object has no attribute 'split'")>                                      
                             ╭────────────────────────── Traceback (most recent call last) ──────────────────────────╮                    
                             │ /home/cauro/prs/caldera/app/contacts/contact_udp.py:21 in start                       │                    
                             │                                                                                       │                    
                             │   18 │   async def start(self):                                                       │                    
                             │   19 │   │   loop = asyncio.get_event_loop()                                          │                    
                             │   20 │   │   udp = self.get_config('app.contact.udp')                                 │                    
                             │ ❱ 21 │   │   addr, port = udp.split(':')                                              │                    
                             │   22 │   │   self.transport, _ = await loop.create_task(loop.create_datagram_endpoint │                    
                             │      self.handler, local_addr=(addr, port)))                                          │                    
                             │   23 │                                                                                │                    
                             │   24 │   async def stop(self):                                                        │                    
                             ╰───────────────────────────────────────────────────────────────────────────────────────╯                    
                             AttributeError: 'NoneType' object has no attribute 'split'                                                   
                    ERROR    Task exception was never retrieved                                                        base_events.py:1821
                             future: <Task finished name='Task-7' coro=<Contact.start() done, defined at                                  
                             /home/cauro/prs/caldera/app/contacts/contact_websocket.py:17>                                                
                             exception=AttributeError("'NoneType' object has no attribute 'split'")>                                      
                             ╭────────────────────────── Traceback (most recent call last) ──────────────────────────╮                    
                             │ /home/cauro/prs/caldera/app/contacts/contact_websocket.py:20 in start                 │                    
                             │                                                                                       │                    
                             │   17 │   async def start(self):                                                       │                    
                             │   18 │   │   web_socket = self.get_config('app.contact.websocket')                    │                    
                             │   19 │   │   try:                                                                     │                    
                             │ ❱ 20 │   │   │   async with websockets.serve(self.handler.handle, *web_socket.split(' │                    
                             │      logger=self.log):                                                                │                    
                             │   21 │   │   │   │   await self.stop_future                                           │                    
                             │   22 │   │                                                                            │                    
                             │   23 │   │   except OSError as e:                                                     │                    
                             ╰───────────────────────────────────────────────────────────────────────────────────────╯                    
                             AttributeError: 'NoneType' object has no attribute 'split'                                                   
                    ERROR    Task exception was never retrieved                                                        base_events.py:1821
                             future: <Task finished name='Task-8' coro=<Contact.start() done, defined at                                  
                             /home/cauro/prs/caldera/app/contacts/contact_tcp.py:21>                                                      
                             exception=AttributeError("'NoneType' object has no attribute 'split'")>                                      
                             ╭────────────────────────── Traceback (most recent call last) ──────────────────────────╮                    
                             │ /home/cauro/prs/caldera/app/contacts/contact_tcp.py:24 in start                       │                    
                             │                                                                                       │                    
                             │    21 │   async def start(self):                                                      │                    
                             │    22 │   │   loop = asyncio.get_event_loop()                                         │                    
                             │    23 │   │   tcp = self.get_config('app.contact.tcp')                                │                    
                             │ ❱  24 │   │   loop.create_task(asyncio.start_server(self.tcp_handler.accept, *tcp.spl │                    
                             │    25 │   │   loop.create_task(self.operation_loop())                                 │                    
                             │    26 │                                                                               │                    
                             │    27 │   async def operation_loop(self):                                             │                    
                             ╰───────────────────────────────────────────────────────────────────────────────────────╯                    
                             AttributeError: 'NoneType' object has no attribute 'split'                                                   
                    ERROR    Task exception was never retrieved                                                        base_events.py:1821
                             future: <Task finished name='Task-9' coro=<Contact.start() done, defined at                                  
                             /home/cauro/prs/caldera/app/contacts/contact_gist.py:62>                                                     
                             exception=AttributeError("'NoneType' object has no attribute 'strip'")>                                      
                             ╭────────────────────────── Traceback (most recent call last) ──────────────────────────╮                    
                             │ /home/cauro/prs/caldera/app/contacts/contact_gist.py:63 in start                      │                    
                             │                                                                                       │                    
                             │    60 │   │   return self.token                                                       │                    
                             │    61 │                                                                               │                    
                             │    62 │   async def start(self):                                                      │                    
                             │ ❱  63 │   │   token = self.get_config('app.contact.gist', '').strip()                 │                    
                             │    64 │   │   if token:                                                               │                    
                             │    65 │   │   │   if self.valid_config(token):                                        │                    
                             │    66 │   │   │   │   self.token = token                                              │                    
                             ╰───────────────────────────────────────────────────────────────────────────────────────╯                    
                             AttributeError: 'NoneType' object has no attribute 'strip'                                                   
                    ERROR    Task exception was never retrieved                                                        base_events.py:1821
                             future: <Task finished name='Task-10' coro=<Contact.start() done, defined at                                 
                             /home/cauro/prs/caldera/app/contacts/contact_slack.py:62> exception=TypeError("expected                      
                             string or bytes-like object, got 'NoneType'")>                                                               
                             ╭────────────────────────── Traceback (most recent call last) ──────────────────────────╮                    
                             │ /home/cauro/prs/caldera/app/contacts/contact_slack.py:63 in start                     │                    
                             │                                                                                       │                    
                             │    60 │   │   return self.key                                                         │                    
                             │    61 │                                                                               │                    
                             │    62 │   async def start(self):                                                      │                    
                             │ ❱  63 │   │   if await self.valid_config():                                           │                    
                             │    64 │   │   │   self.key = self.get_config('app.contact.slack.api_key')             │                    
                             │    65 │   │   │   self.channelid = self.get_config('app.contact.slack.channel_id')    │                    
                             │    66 │   │   │   self.botid = self.get_config('app.contact.slack.bot_id')            │                    
                             │                                                                                       │                    
                             │ /home/cauro/prs/caldera/app/contacts/contact_slack.py:78 in valid_config              │                    
                             │                                                                                       │                    
                             │    75 │   │   │   await asyncio.sleep(15)                                             │                    
                             │    76 │                                                                               │                    
                             │    77 │   async def valid_config(self):                                               │                    
                             │ ❱  78 │   │   return                                                                  │                    
                             │       re.compile(pattern='xoxb-[0-9]{13,13}-[0-9]{13,13}-[a-zA-Z0-9]{24,24}').match(s │                    
                             │       onfig('app.contact.slack.api_key'))                                             │                    
                             │    79 │                                                                               │                    
                             │    80 │   async def handle_beacons(self, beacons):                                    │                    
                             │    81 │   │   """                                                                     │                    
                             ╰───────────────────────────────────────────────────────────────────────────────────────╯                    
                             TypeError: expected string or bytes-like object, got 'NoneType'                                              
                    ERROR    Task exception was never retrieved                                                        base_events.py:1821
                             future: <Task finished name='Task-11' coro=<Contact.start() done, defined at                                 
                             /home/cauro/prs/caldera/app/contacts/contact_dns.py:23>                                                      
                             exception=AttributeError("'NoneType' object has no attribute 'split'")>                                      
                             ╭────────────────────────── Traceback (most recent call last) ──────────────────────────╮                    
                             │ /home/cauro/prs/caldera/app/contacts/contact_dns.py:26 in start                       │                    
                             │                                                                                       │                    
                             │    23 │   async def start(self):                                                      │                    
                             │    24 │   │   loop = asyncio.get_event_loop()                                         │                    
                             │    25 │   │   dns = self.get_config('app.contact.dns.socket')                         │                    
                             │ ❱  26 │   │   addr, port = dns.split(':')                                             │                    
                             │    27 │   │   self.transport, _ = await loop.create_datagram_endpoint(lambda: self.ha │                    
                             │       local_addr=(addr, port))                                                        │                    
                             │    28 │                                                                               │                    
                             │    29 │   async def stop(self):                                                       │                    
                             ╰───────────────────────────────────────────────────────────────────────────────────────╯                    
                             AttributeError: 'NoneType' object has no attribute 'split'                                                   
                    ERROR    Task exception was never retrieved                                                        base_events.py:1821
                             future: <Task finished name='Task-14' coro=<Tunnel.start() done, defined at                                  
                             /home/cauro/prs/caldera/app/contacts/tunnels/tunnel_ssh.py:17>                                               
                             exception=AttributeError("'NoneType' object has no attribute 'split'")>                                      
                             ╭────────────────────────── Traceback (most recent call last) ──────────────────────────╮                    
                             │ /home/cauro/prs/caldera/app/contacts/tunnels/tunnel_ssh.py:19 in start                │                    
                             │                                                                                       │                    
                             │   16 │                                                                                │                    
                             │   17 │   async def start(self):                                                       │                    
                             │   18 │   │   ssh_endpoint = self.get_config('app.contact.tunnel.ssh.socket')          │                    
                             │ ❱ 19 │   │   addr, port = ssh_endpoint.split(':')                                     │                    
                             │   20 │   │   host_key_filename = self.get_config('app.contact.tunnel.ssh.host_key_fil │                    
                             │   21 │   │   host_key_filepath = os.path.join('conf', 'ssh_keys', host_key_filename)  │                    
                             │   22 │   │   host_key_passphrase =                                                    │                    
                             │      self.get_config('app.contact.tunnel.ssh.host_key_passphrase')                    │                    
                             ╰───────────────────────────────────────────────────────────────────────────────────────╯                    
                             AttributeError: 'NoneType' object has no attribute '

@uruwhy uruwhy closed this Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants