<#3833 fix: Fill in config defaults before checkin...
# meltano-repo-activity
g
#3833 fix: Fill in config defaults before checking required settings, regardless of JSON schema keyword order Pull request opened by edgarrmondragon Summary Since 4bbbb58 ("Sort metadata keys meaningfully in generated JSON schemas"),
PropertiesList(...).to_dict()
lists
required
before
properties
. The config validator from
extend_validator_with_defaults
only filled in defaults in its
properties
handler, and JSON Schema keywords are checked in schema order. So in 0.55.0b5, a required setting with a default fails validation when it's omitted, which it didn't in 0.54. Found through MeltanoLabs/tap-mongodb#190. Its
filter_collections
setting is
required=True, default=[]
, and the Meltano integration test (which doesn't set it) now fails with
Config validation error: 'filter_collections' is a required property
. The same config passes with singer-sdk 0.54.6.
Copy code
0.54.6     config schema keys: ['type', 'properties', 'required', '$schema']
0.55.0b5   config schema keys: ['$schema', 'type', 'required', 'properties']
Fix Every keyword handler of the extended validator now fills in the (sub)schema's property defaults before it runs. So the defaults are in place before whichever keyword comes first, whether that's
required
,
properties
, or an earlier
if
that checks a defaulted setting. Filling them in is idempotent, and the cost (a few
setdefault
calls per keyword) is negligible for config validation. This keeps 4bbbb58's key ordering. Tests •
test_tap_config_required_default
checks that a generated schema lists
required
before
properties
, and that a required setting with a default can be omitted. •
test_config_defaults_independent_of_keyword_order
validates
{}
against every ordering of a schema with
type
, `if`/`then` on a defaulted setting,
required
and
properties
. All orderings give the same error and the same filled-in config. Both fail without the fix; the second also fails with this PR's first version, which only filled defaults in the
required
and
properties
handlers. Core and contrib tests, mypy and ty pass. tap-mongodb's discovery with a config that omits
filter_collections
succeeds again with this branch installed. Summary by Sourcery Make configuration default handling independent of JSON Schema keyword ordering so required settings with defaults validate correctly when omitted. Bug Fixes: • Ensure required settings with defaults are populated before validation, regardless of JSON Schema keyword order. Tests: • Add coverage for omitting a required setting with a default when generated schemas list
required
before
properties
. meltano/sdk