Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to eliminate null defaults in generated schemas (notably for complex/collection parameters like property restrictions) to prevent downstream config generators from emitting invalid JSON such as "Node_Property_Restrictions": null, which EMOD rejects (see issue #323).
Changes:
- Removes
HasValidDefault()fromIComplexJsonConfigurableand deletes overrides across several implementations. - Updates schema/config plumbing in
utils/Configure.cppfor complex types and default/missing-parameter behavior. - Refactors parts of
StandardInterventionDistributionEventCoordinatorand simplifiesPropertyRestrictionsschema typing logic.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/JsonConfigurableCollection.h | Removes HasValidDefault() override from complex collection helper. |
| utils/Configure.h | Removes HasValidDefault() from IComplexJsonConfigurable and related overrides in nested config structs. |
| utils/Configure.cpp | Adjusts complex-type schema/default handling and missing-param behavior. |
| interventions/WaningEffectCombo.h | Removes HasValidDefault() override from WaningEffectCollection. |
| Eradication/VectorSpeciesParameters.h | Removes HasValidDefault() override. |
| Eradication/TargetingLogic.h | Removes HasValidDefault() declaration. |
| Eradication/TargetingLogic.cpp | Removes HasValidDefault() definition. |
| Eradication/StandardEventCoordinator.h | Changes factory registration macro usage and adds explicit Configure declaration. |
| Eradication/StandardEventCoordinator.cpp | Formatting refactors and minor logic reshaping; touches logging line. |
| Eradication/PropertyRestrictions.h | Adds include and removes HasValidDefault() override. |
| Eradication/PropertyRestrictions.cpp | Simplifies schema typename assignment and minor formatting changes. |
| Eradication/DemographicRestrictions.cpp | Formatting-only changes. |
Suppressed comments (1)
utils/Configure.cpp:1522
- initConfigComplexType no longer sets a parameter-level default for complex types. For fields like Node_Property_Restrictions / Property_Restrictions_Within_Node (whose type schema default is []), schema consumers can fall back to emitting
nullor no default, which does not match the engine expectation (array) and is the root of issue #323. Instead of removing defaults entirely, copy the complex type's type-schema "default" only when it exists and is non-null.
json::QuickBuilder custom_schema = pVariable->GetSchema();
if( _dryrun )
{
std::string custom_type_label = (std::string) custom_schema[ _typename_label() ].As<json::String>();
json::String custom_type_label_as_json_string = json::String( custom_type_label );
newParamSchema["type"] = json::String( custom_type_label_as_json_string );
newParamSchema["description"] = json::String( description );
// Do not update with a null object
json::QuickInterpreter s_check(custom_schema);
if( s_check.Exist(_typeschema_label()) )
{
jsonSchemaBase[ custom_type_label ] = custom_schema[ _typeschema_label() ];
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Should address EMOD-Hub/issues-and-discussions#323