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

Can not access elements of a configuration if the keys are numbers #131

Open
geier1993 opened this issue Jun 14, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@geier1993
Copy link
Contributor

What happened?

I have a YAML file that contains a map with integer keys, e.g.

8:
  subMap;
1333534:
  subMap:

The structure itself is meant to be generic, in my case I am refering to paramId but it can be any other MARS key.

In the code I'm now iterating with

for (const auto& key: valueMap.keys()) {
    auto val = valueMap.getSubConfiguration(key);
}

which should work for consistency.
However, in this case it will return an empty map and thus distorts the workflow.

To avoid the problem, I have to put strings as keys explicitly in the map:

"8": ...
"1333434": ...

Considering that the whole eckit::Configuration is working with string keys and a valid YAML file may contain both keys (i.e. 8 and "8"), I think it is the right behaviour not to try to look up an int key.

However, it is also not failing with the expected "ConfigurationNotFound".

What are the steps to reproduce the bug?

Well...

Read a YAML file with eckit::YAMLConfiguration and iterate a map....

Version

develop

Platform (OS and architecture)

MacOS

Relevant log output

No response

Accompanying data

No response

Organisation

ECMWF

@geier1993 geier1993 added the bug Something isn't working label Jun 14, 2024
@wdeconinck
Copy link
Member

See answer by @tlmquintino in older closed issue #21 .
Configuration API does not support numbers as keys, even if YAML supports this.

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

2 participants