inmanta / inmanta-core

Inmanta is an automation and orchestration tool
https://inmanta.com
Apache License 2.0
27 stars 7 forks source link

Duplication of instantiation location in error report #5526

Open Hugo-Inmanta opened 1 year ago

Hugo-Inmanta commented 1 year ago

In the last line of the trace: "instantiated at ..." the location is mentioned twice : "... ./main.cf:32,./main.cf:32)"

inmanta.ast.AttributeException: Could not set attribute `yang_credentials` on instance `srlinux::GnmiDevice (instantiated at >>>>./main.cf:32,./main.cf:32)<<<<` (reported in Construct(srlinux::GnmiDevice) (./main.cf:32))

Full trace:

Traceback (most recent call last):
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/ast/statements/assign.py", line 326, in execute
    ExecutionUnit._unsafe_execute(self)
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/execute/runtime.py", line 915, in _unsafe_execute
    self.result.set_value(value, self.expression.location)
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/execute/runtime.py", line 377, in set_value
    raise DoubleSetException(self, None, value, location)
inmanta.ast.DoubleSetException: value set twice:
    old value: yang::Credentials (instantiated at ./main.cf:36)
        set at ./main.cf:36
    new value: yang::Credentials (instantiated at ./main.cf:36)
        set at ./main.cf:36
 (reported in Construct(srlinux::GnmiDevice) (./main.cf:32))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/app.py", line 874, in app
    options.func(options)
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/app.py", line 655, in export
    raise exp
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/app.py", line 634, in export
    (types, scopes) = do_compile()
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/compiler/__init__.py", line 80, in do_compile
    compiler.handle_exception(e)
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/compiler/__init__.py", line 255, in handle_exception
    self._handle_exception_export(e)
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/compiler/__init__.py", line 261, in _handle_exception_export
    raise exception
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/compiler/__init__.py", line 253, in handle_exception
    self._handle_exception_datatrace(exception)
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/compiler/__init__.py", line 265, in _handle_exception_datatrace
    raise exception
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/compiler/__init__.py", line 75, in do_compile
    success = sched.run(compiler, statements, blocks)
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/execute/scheduler.py", line 406, in run
    next.execute()
  File "/opt/inmanta/lib64/python3.9/site-packages/inmanta/ast/statements/assign.py", line 337, in execute
    raise AttributeException(self.stmt, self.instance, self.attribute_name, e)
inmanta.ast.AttributeException: Could not set attribute `yang_credentials` on instance `srlinux::GnmiDevice (instantiated at ./main.cf:32,./main.cf:32)` (reported in Construct(srlinux::GnmiDevice) (./main.cf:32))
sanderr commented 1 year ago

Could it be this instance is actually constructed twice, then compacted with an index match? This is useful information, so I wouldn't want to just drop the multiple occurrences, but perhaps we can make it more clear?