Closed alessandrothea closed 3 years ago
A case of unintentional exception hiding.
The cmd.CmdObj()
produces an incomplete record
, which is okay up until a finalizing .pod()
is called.
The Command.pod()
requires (required) that the CmdObj
is already complete (its own .pod()
is called). Since it isn't complete an AttributeError
is raised which is then internally caught and wrongly interpreted in the outer Command.pod()
as data
attribute missing. Since data
is optional, the code happily continues on its merry way emitting the object the test shows.
The fix is to probe that fields exist without triggering their value's .pod()
call so any field values that happen to be incomplete records will have their AttributeError
raised later.
Commit inbound with test_issue13.py
holding test_hidden_attrerr()
to reproduce this issue and show the code now correctly throws AttributeError
to the outer caller.
About the test code itself. It's never worthwhile passing an incomplete record R as a field value to a parent record P as this is a pass-by-value. Subsequent completion of the R -> R' will not be reflected in the passed copy. The field of P will need to be explicitly set to the completed R'.
The new test exercises this completion.
Of course, moo should properly complain if this isn't done correctly, which it should now!
Hi, when preparing the first python-based configuration for the minidaq in
dunedaq-v2.2.0
I stumbled on the following issue: a schema validation error can be hidden if it originates from an "optional" field.Minimal example below based on the appfwk schema (runs off the
appfwk/schema
):cmd.CmdObj()
without the requiredmodules
filed correctly fails,cmd.Command(id=cmd.CmdId("aaa"), data=cmd.CmdObj())
doesn't. Note thatdata
is optionaldata
field at all.Minimal example
Results in