Skip to content

Ensure no null values in schema - #227

Merged
kfrey-idm merged 5 commits into
mainfrom
bug_fix
Aug 8, 2026
Merged

Ensure no null values in schema#227
kfrey-idm merged 5 commits into
mainfrom
bug_fix

Conversation

@kfrey-idm

Copy link
Copy Markdown
Member

@kfrey-idm
kfrey-idm requested a lite review from Copilot August 7, 2026 18:19
@kfrey-idm kfrey-idm self-assigned this Aug 7, 2026
@kfrey-idm kfrey-idm added the bug label Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() from IComplexJsonConfigurable and deletes overrides across several implementations.
  • Updates schema/config plumbing in utils/Configure.cpp for complex types and default/missing-parameter behavior.
  • Refactors parts of StandardInterventionDistributionEventCoordinator and simplifies PropertyRestrictions schema 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 null or 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.

Comment thread Eradication/PropertyRestrictions.cpp
Comment thread Eradication/PropertyRestrictions.h
Comment thread Eradication/StandardEventCoordinator.h
Comment thread Eradication/StandardEventCoordinator.cpp Outdated
@kfrey-idm
kfrey-idm merged commit 1c49928 into main Aug 8, 2026
16 checks passed
@kfrey-idm
kfrey-idm deleted the bug_fix branch August 8, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants