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

ConfigSchema type check bug #22

Closed
jliersch opened this issue Aug 29, 2024 · 3 comments
Closed

ConfigSchema type check bug #22

jliersch opened this issue Aug 29, 2024 · 3 comments

Comments

@jliersch
Copy link
Contributor

jliersch commented Aug 29, 2024

Situation

When type checking a double as a number defined in a ConfigSchema, I got an error for invalid type (cf. envire/envire-envire_types#5 (comment)). Investigating the type of the item before the check in has_corresponding_type (see below) it seems like the type of the corresponding config item is undefined at config_item.getOrCreateAtom()->getType().

bool ConfigSchema::has_corresponding_type(ConfigItem &config_item, const std::string &type)
{
if (type == "object")
return config_item.isMap();
if (type == "array")
return config_item.isVector();
// TODO: for some reason ConfigAtom STRING_TYPE needs to be tested with testType() instead of getType() to detect its type..
if (type == "string")
return config_item.getOrCreateAtom()->testType(ConfigAtom::STRING_TYPE);
return std::find(SCHEMA_ATOM_TYPES.at(type).begin(), SCHEMA_ATOM_TYPES.at(type).end(),
config_item.getOrCreateAtom()->getType()) != SCHEMA_ATOM_TYPES.at(type).end();
}

Task

Ensure the type is set prior to calling getType or use testType for atomic types.

@jliersch
Copy link
Contributor Author

Closed with merge of #23

@jliersch jliersch reopened this Aug 29, 2024
@jliersch
Copy link
Contributor Author

The same problem also could occur when using minimum or maximum values in a schema.

@jliersch
Copy link
Contributor Author

Closed with merge of #24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant