Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: AttributeError: 'NoneType' object has no attribute 'variables_exec' #344

Open
0hsn opened this issue Dec 5, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@0hsn
Copy link
Member

0hsn commented Dec 5, 2024

2024-12-05 12:47:19.214 | DEBUG    | chk.modules.workflow:call:198 - FileContext(options={}, arguments={}, document={'version': 'default:validation:0.7.2', 'asserts': [{'type': 'List', 'actual': '<% _data.body %>'}, {'type': 'Map', 'actual': '<% _data.body.1 %>'}, {'type': 'MapHasKeys', 'actual': '<% _data.body.1 %>', 'expected': ['postId', 'id', 'name', 'email', 'body']}], 'expose': ['<% _asserts_response %>']}, filepath='/Users/mlbdmba21/Works/chkware/cli/tests/resources/storage/spec_docs/workflow_cases/jsonplaceholder/get-comments-valid.yml', filepath_hash='a6fff212b3f0af05b05ea69139f4eeb7d984371b6972b1c7a37817545c573cf5')
2024-12-05 12:47:19.214 | DEBUG    | chk.modules.workflow:call:199 - ExecuteContext(options={'dump': True, 'format': True, 'debug': True}, arguments={'variables': {}})
2024-12-05 12:47:19.214 | ERROR    | chk.modules.workflow:call:230 - Unsupported document exception
Traceback (most recent call last):

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code

  File "/Users/mlbdmba21/Works/chkware/cli/chk/__main__.py", line 8, in <module>
    chk(obj={})
    └ <Group chk>

  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           │    │     │       └ {'obj': {'debug': True}}
           │    │     └ ()
           │    └ <function BaseCommand.main at 0x10104e0c0>
           └ <Group chk>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         │    │      └ <click.core.Context object at 0x100d03410>
         │    └ <function MultiCommand.invoke at 0x10104f2e0>
         └ <Group chk>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
           │               │       │       │      └ <click.core.Context object at 0x1030f3190>
           │               │       │       └ <function Command.invoke at 0x10104eca0>
           │               │       └ <Command workflow>
           │               └ <click.core.Context object at 0x1030f3190>
           └ <function MultiCommand.invoke.<locals>._process_result at 0x100cf2520>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           │   │      │    │           │   └ {'file': 'tests/resources/storage/spec_docs/workflow_cases/jsonplaceholder/get-comments-valid.yml', 'no_format': False, 'vari...
           │   │      │    │           └ <click.core.Context object at 0x1030f3190>
           │   │      │    └ <function workflow at 0x1031b42c0>
           │   │      └ <Command workflow>
           │   └ <function Context.invoke at 0x10104d620>
           └ <click.core.Context object at 0x1030f3190>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
                       │       └ {'file': 'tests/resources/storage/spec_docs/workflow_cases/jsonplaceholder/get-comments-valid.yml', 'no_format': False, 'vari...
                       └ ()
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           │ │                       │       └ {'file': 'tests/resources/storage/spec_docs/workflow_cases/jsonplaceholder/get-comments-valid.yml', 'no_format': False, 'vari...
           │ │                       └ ()
           │ └ <function get_current_context at 0x101012c00>
           └ <function workflow at 0x1031b4c20>

  File "/Users/mlbdmba21/Works/chkware/cli/chk/console/main.py", line 169, in workflow
    workflow_executor.execute(ctx, execution_ctx, after_hook)
    │                 │       │    │              └ <function after_hook at 0x1031b4ae0>
    │                 │       │    └ ExecuteContext(options={'dump': True, 'format': True, 'debug': True}, arguments={'variables': {}})
    │                 │       └ FileContext(options={}, arguments={}, document={'version': 'default:validation:0.7.2', 'asserts': [{'type': 'List', 'actual':...
    │                 └ <function execute at 0x103188e00>
    └ <module 'chk.modules.workflow' from '/Users/mlbdmba21/Works/chkware/cli/chk/modules/workflow/__init__.py'>

  File "/Users/mlbdmba21/Works/chkware/cli/chk/modules/workflow/__init__.py", line 260, in execute
    exr = call(file_ctx=ctx, exec_ctx=exec_ctx)
          │             │             └ ExecuteContext(options={'dump': True, 'format': True, 'debug': True}, arguments={'variables': {}})
          │             └ FileContext(options={}, arguments={}, document={'version': 'default:validation:0.7.2', 'asserts': [{'type': 'List', 'actual':...
          └ <function call at 0x1031898a0>

> File "/Users/mlbdmba21/Works/chkware/cli/chk/modules/workflow/__init__.py", line 207, in call
    wflow_doc = WorkflowDocument.from_file_context(file_ctx)
                │                │                 └ FileContext(options={}, arguments={}, document={'version': 'default:validation:0.7.2', 'asserts': [{'type': 'List', 'actual':...
                │                └ <staticmethod(<function WorkflowDocument.from_file_context at 0x10318bba0>)>
                └ <class 'chk.modules.workflow.WorkflowDocument'>

  File "/Users/mlbdmba21/Works/chkware/cli/chk/modules/workflow/__init__.py", line 60, in from_file_context
    DocumentVersionMaker.verify_if_allowed(doc_ver, VERSION_SCOPE)
    │                    │                 │        └ ['workflow']
    │                    │                 └ DocumentVersion(original_version_str='default:validation:0.7.2', provider='default', doc_type='validation', doc_type_ver='0.7...
    │                    └ <staticmethod(<function DocumentVersionMaker.verify_if_allowed at 0x10316c360>)>
    └ <class 'chk.infrastructure.version.DocumentVersionMaker'>

  File "/Users/mlbdmba21/Works/chkware/cli/chk/infrastructure/version.py", line 146, in verify_if_allowed
    raise RuntimeError("Unsupported document exception")

RuntimeError: Unsupported document exception
2024-12-05 12:47:19.220 | ERROR    | chk.modules.workflow:execute:260 - An error has been caught in function 'execute', process 'MainProcess' (1961), thread 'MainThread' (8413499200):
Traceback (most recent call last):

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code

  File "/Users/mlbdmba21/Works/chkware/cli/chk/__main__.py", line 8, in <module>
    chk(obj={})
    └ <Group chk>

  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           │    │     │       └ {'obj': {'debug': True}}
           │    │     └ ()
           │    └ <function BaseCommand.main at 0x10104e0c0>
           └ <Group chk>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         │    │      └ <click.core.Context object at 0x100d03410>
         │    └ <function MultiCommand.invoke at 0x10104f2e0>
         └ <Group chk>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
           │               │       │       │      └ <click.core.Context object at 0x1030f3190>
           │               │       │       └ <function Command.invoke at 0x10104eca0>
           │               │       └ <Command workflow>
           │               └ <click.core.Context object at 0x1030f3190>
           └ <function MultiCommand.invoke.<locals>._process_result at 0x100cf2520>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           │   │      │    │           │   └ {'file': 'tests/resources/storage/spec_docs/workflow_cases/jsonplaceholder/get-comments-valid.yml', 'no_format': False, 'vari...
           │   │      │    │           └ <click.core.Context object at 0x1030f3190>
           │   │      │    └ <function workflow at 0x1031b42c0>
           │   │      └ <Command workflow>
           │   └ <function Context.invoke at 0x10104d620>
           └ <click.core.Context object at 0x1030f3190>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
                       │       └ {'file': 'tests/resources/storage/spec_docs/workflow_cases/jsonplaceholder/get-comments-valid.yml', 'no_format': False, 'vari...
                       └ ()
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           │ │                       │       └ {'file': 'tests/resources/storage/spec_docs/workflow_cases/jsonplaceholder/get-comments-valid.yml', 'no_format': False, 'vari...
           │ │                       └ ()
           │ └ <function get_current_context at 0x101012c00>
           └ <function workflow at 0x1031b4c20>

  File "/Users/mlbdmba21/Works/chkware/cli/chk/console/main.py", line 169, in workflow
    workflow_executor.execute(ctx, execution_ctx, after_hook)
    │                 │       │    │              └ <function after_hook at 0x1031b4ae0>
    │                 │       │    └ ExecuteContext(options={'dump': True, 'format': True, 'debug': True}, arguments={'variables': {}})
    │                 │       └ FileContext(options={}, arguments={}, document={'version': 'default:validation:0.7.2', 'asserts': [{'type': 'List', 'actual':...
    │                 └ <function execute at 0x103188e00>
    └ <module 'chk.modules.workflow' from '/Users/mlbdmba21/Works/chkware/cli/chk/modules/workflow/__init__.py'>

> File "/Users/mlbdmba21/Works/chkware/cli/chk/modules/workflow/__init__.py", line 260, in execute
    exr = call(file_ctx=ctx, exec_ctx=exec_ctx)
          │             │             └ ExecuteContext(options={'dump': True, 'format': True, 'debug': True}, arguments={'variables': {}})
          │             └ FileContext(options={}, arguments={}, document={'version': 'default:validation:0.7.2', 'asserts': [{'type': 'List', 'actual':...
          └ <function call at 0x1031898a0>

  File "/Users/mlbdmba21/Works/chkware/cli/chk/modules/workflow/__init__.py", line 238, in call
    extra=exec_report,

UnboundLocalError: cannot access local variable 'exec_report' where it is not associated with a value
2024-12-05 12:47:19.222 | ERROR    | chk.modules.workflow:execute:264 - 'NoneType' object has no attribute 'variables_exec'
Traceback (most recent call last):

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code

  File "/Users/mlbdmba21/Works/chkware/cli/chk/__main__.py", line 8, in <module>
    chk(obj={})
    └ <Group chk>

  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           │    │     │       └ {'obj': {'debug': True}}
           │    │     └ ()
           │    └ <function BaseCommand.main at 0x10104e0c0>
           └ <Group chk>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         │    │      └ <click.core.Context object at 0x100d03410>
         │    └ <function MultiCommand.invoke at 0x10104f2e0>
         └ <Group chk>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
           │               │       │       │      └ <click.core.Context object at 0x1030f3190>
           │               │       │       └ <function Command.invoke at 0x10104eca0>
           │               │       └ <Command workflow>
           │               └ <click.core.Context object at 0x1030f3190>
           └ <function MultiCommand.invoke.<locals>._process_result at 0x100cf2520>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           │   │      │    │           │   └ {'file': 'tests/resources/storage/spec_docs/workflow_cases/jsonplaceholder/get-comments-valid.yml', 'no_format': False, 'vari...
           │   │      │    │           └ <click.core.Context object at 0x1030f3190>
           │   │      │    └ <function workflow at 0x1031b42c0>
           │   │      └ <Command workflow>
           │   └ <function Context.invoke at 0x10104d620>
           └ <click.core.Context object at 0x1030f3190>
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
                       │       └ {'file': 'tests/resources/storage/spec_docs/workflow_cases/jsonplaceholder/get-comments-valid.yml', 'no_format': False, 'vari...
                       └ ()
  File "/Users/mlbdmba21/.local/share/virtualenvs/cli-rKd01vgv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           │ │                       │       └ {'file': 'tests/resources/storage/spec_docs/workflow_cases/jsonplaceholder/get-comments-valid.yml', 'no_format': False, 'vari...
           │ │                       └ ()
           │ └ <function get_current_context at 0x101012c00>
           └ <function workflow at 0x1031b4c20>

  File "/Users/mlbdmba21/Works/chkware/cli/chk/console/main.py", line 169, in workflow
    workflow_executor.execute(ctx, execution_ctx, after_hook)
    │                 │       │    │              └ <function after_hook at 0x1031b4ae0>
    │                 │       │    └ ExecuteContext(options={'dump': True, 'format': True, 'debug': True}, arguments={'variables': {}})
    │                 │       └ FileContext(options={}, arguments={}, document={'version': 'default:validation:0.7.2', 'asserts': [{'type': 'List', 'actual':...
    │                 └ <function execute at 0x103188e00>
    └ <module 'chk.modules.workflow' from '/Users/mlbdmba21/Works/chkware/cli/chk/modules/workflow/__init__.py'>

> File "/Users/mlbdmba21/Works/chkware/cli/chk/modules/workflow/__init__.py", line 261, in execute
    cb({ctx.filepath_hash: exr.variables_exec.data})
    │   │   │              └ None
    │   │   └ _tuplegetter(4, 'Alias for field number 4')
    │   └ FileContext(options={}, arguments={}, document={'version': 'default:validation:0.7.2', 'asserts': [{'type': 'List', 'actual':...
    └ <function after_hook at 0x1031b4ae0>

AttributeError: 'NoneType' object has no attribute 'variables_exec'

@0hsn 0hsn added the bug Something isn't working label Dec 5, 2024
@0hsn 0hsn changed the title Fix: Error _AttributeError: 'NoneType' object has no attribute 'variables_exec'_ Fix: AttributeError: 'NoneType' object has no attribute 'variables_exec' Dec 5, 2024
@0hsn
Copy link
Member Author

0hsn commented Dec 5, 2024

Remarks

  1. When exception thrown earlier e.g. Validation exception happens, then on later steps other required variables can't be created (because the flow continues) - solution refactor module driver code flow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant