Is your feature request related to a problem? Please describe.
I tried building a custom schema (and custom message types, but that's irrelevant here) for FDB. I came up with a schema similar to:
I.e. if c is present in the key, b is optional, but if d is present, b is required. I expected this to work, however the following sampe code fails:
#include <fdb5/api/FDB.h>
#include <eckit/runtime/Main.h>
int main(int argc, char** argv) {
eckit::Main::initialise(argc, argv);
auto fdb = fdb5::FDB{};
fdb.archive(fdb5::Key({{"a", "1"}, {"b", "2"}, {"c", "4"}}), "foo", 4); // works fine
fdb.archive(fdb5::Key({{"a", "1"}, {"b", "2"}, {"d", "4"}}), "bar", 4); // crashes
}
when compiled & run as follows:
g++ -o badschema badschema.cpp -lfdb5 -leckit && ./badschema
The reported error is:
terminate called after throwing an instance of 'eckit::SeriousBug'
what(): SeriousBug: Key::get() failed for [c] in {a=1,b=2,d=4} in (/src/fdb/src/fdb5/database/Key.cc +192 get)
I.e. FDB tries to get the value for "c" in the second archive call, I guess because it accidentally tries to match it agains the first (instead of the second) schema rule.
I've been in contact with @simondsmart, who suggested to use the schema
instead. However, the test code fails with the same issue (also the schema doesn't encode that b would be required for d).
Describe the solution you'd like
I'd like to see both of the two schemas above work with the provided example code.
Describe alternatives you've considered
If it's impossible to make those schema work, FDB should generate an understandable error message, explaining that the schema is invalid instead of accepting some keys for storage before crashing with other keys.
Additional context
No response
Organisation
MPIM
Is your feature request related to a problem? Please describe.
I tried building a custom schema (and custom message types, but that's irrelevant here) for FDB. I came up with a schema similar to:
I.e. if
cis present in the key,bis optional, but ifdis present,bis required. I expected this to work, however the following sampe code fails:when compiled & run as follows:
g++ -o badschema badschema.cpp -lfdb5 -leckit && ./badschemaThe reported error is:
I.e. FDB tries to get the value for "c" in the second
archivecall, I guess because it accidentally tries to match it agains the first (instead of the second) schema rule.I've been in contact with @simondsmart, who suggested to use the schema
instead. However, the test code fails with the same issue (also the schema doesn't encode that
bwould be required ford).Describe the solution you'd like
I'd like to see both of the two schemas above work with the provided example code.
Describe alternatives you've considered
If it's impossible to make those schema work, FDB should generate an understandable error message, explaining that the schema is invalid instead of accepting some keys for storage before crashing with other keys.
Additional context
No response
Organisation
MPIM