Repository navigation
Stop one malformed provider from breaking discovery for all providers - #72854
Merged
Merged
Conversation
kaxil
force-pushed
the
provider-discovery-resilience
branch
from
September 10, 2026 01:05
e18036f to
29e7096
Compare
`provider_schema_validator.validate()` was called unwrapped inside the entry-point loop in provider discovery, and nothing up either call chain caught it. A single installed provider whose metadata fails validation therefore took down the whole provider list rather than just its own entry: every provider after it in entry-point order was never registered, `initialize_providers_list()` raised, and because `provider_info_cache` does not memoise failures it raised again on every subsequent access. Both the scheduler/API-server path and the worker path in the Task SDK share this loop. Only `jsonschema.ValidationError` is caught. A `SchemaError` or `UnknownType` means the schema itself is broken rather than the provider, and swallowing those would report one "provider does not conform" warning per installed provider while naming the wrong component. `package-name` is not in the runtime schema's required list, so validation passing did not guarantee it was present and the subscript below could still raise an uncaught `KeyError`. That is now the same warn-and-skip. The package-name mismatch check stays fatal, since that is a packaging error rather than unusable metadata.
kaxil
force-pushed
the
provider-discovery-resilience
branch
from
September 10, 2026 11:39
29e7096 to
def5cd6
Compare
kaxil
marked this pull request as ready for review
September 10, 2026 13:35
potiuk
approved these changes
Sep 10, 2026
Member
|
Should we backport it to 3.3.2 ? |
imrichardwu
pushed a commit
to imrichardwu/airflow
that referenced
this pull request
Sep 11, 2026
…apache#72854) `provider_schema_validator.validate()` was called unwrapped inside the entry-point loop in provider discovery, and nothing up either call chain caught it. A single installed provider whose metadata fails validation therefore took down the whole provider list rather than just its own entry: every provider after it in entry-point order was never registered, `initialize_providers_list()` raised, and because `provider_info_cache` does not memoise failures it raised again on every subsequent access. Both the scheduler/API-server path and the worker path in the Task SDK share this loop. Only `jsonschema.ValidationError` is caught. A `SchemaError` or `UnknownType` means the schema itself is broken rather than the provider, and swallowing those would report one "provider does not conform" warning per installed provider while naming the wrong component. `package-name` is not in the runtime schema's required list, so validation passing did not guarantee it was present and the subscript below could still raise an uncaught `KeyError`. That is now the same warn-and-skip. The package-name mismatch check stays fatal, since that is a packaging error rather than unusable metadata.
xvega
pushed a commit
to xvega/airflow
that referenced
this pull request
Sep 13, 2026
…apache#72854) `provider_schema_validator.validate()` was called unwrapped inside the entry-point loop in provider discovery, and nothing up either call chain caught it. A single installed provider whose metadata fails validation therefore took down the whole provider list rather than just its own entry: every provider after it in entry-point order was never registered, `initialize_providers_list()` raised, and because `provider_info_cache` does not memoise failures it raised again on every subsequent access. Both the scheduler/API-server path and the worker path in the Task SDK share this loop. Only `jsonschema.ValidationError` is caught. A `SchemaError` or `UnknownType` means the schema itself is broken rather than the provider, and swallowing those would report one "provider does not conform" warning per installed provider while naming the wrong component. `package-name` is not in the runtime schema's required list, so validation passing did not guarantee it was present and the subscript below could still raise an uncaught `KeyError`. That is now the same warn-and-skip. The package-name mismatch check stays fatal, since that is a packaging error rather than unusable metadata.
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.
Summary
One installed provider whose metadata this Airflow version does not recognise currently takes down provider discovery for every provider in the process, not just its own entry.
provider_schema_validator.validate(provider_info)sits unwrapped inside the entry-point loop, and nothing up either call chain catches it.grep -c ValidationErrorreturns 0 in bothproviders_manager.pyandproviders_manager_runtime.py. The consequences:initialize_providers_list()raises.provider_info_cachedoes not memoise failures, so it raises again on every subsequent access rather than settling into a degraded state.airflow-core/src/airflow/providers_manager.py, and workers viatask-sdk/src/airflow/sdk/providers_manager_runtime.py.With
[core] lazy_discover_providers = False, discovery also runs from the eager-init block inairflow/__init__.py, soimport airflowitself raises. That setting defaults toTrue, so the usual reach is the first access to the providers manager rather than import time.It also contradicts the documented contract
The docstring on the very function doing the validation says the runtime schema is deliberately the lenient one:
A schema violation aborting all discovery is the opposite of relaxed. #71104 declined to tighten this same runtime schema for exactly this reason, and #72853 initially added a
patternto it before backing that out on the same grounds. The fragility is what makes those tightenings unsafe, so removing it also unblocks legitimate schema work later.What changes
The offending provider is logged with its package name and skipped; the rest load normally. The scope of the
tryis the singlevalidate()call, so the package-name mismatch check below it still fails loudly, since that is a packaging error rather than unusable metadata.Only
jsonschema.ValidationErroris caught. ASchemaErrororUnknownTypemeans the schema itself is broken rather than any provider, and_create_provider_info_schema_validatornever callscheck_schema, so such a defect surfaces lazily inside this loop. Catching it here would emit one "provider does not conform" warning per installed provider, register nothing, and name the wrong component, replacing a single loud failure with N misleading ones.A second, closely related hole is fixed alongside it.
package-nameis not in the runtime schema'srequiredlist, sovalidate()passes for metadata that omits it and the subscript below then raised an uncaughtKeyError-- the same "one provider aborts discovery for all" failure this PR exists to remove. It gets the same warn-and-skip.Not addressed here
entry_point.load()()on the line above is also unwrapped, so a provider that raises while producing its own metadata still aborts discovery the same way. That is a different failure mode with a different judgement call about whether an unloadable provider should be visible or silent, so it is left alone rather than folded in.On the tests
The three cases drive the real schema validator rather than a mock, so they cannot be satisfied by catching an exception type jsonschema never raises. Against
apache/mainthe first two fail (ValidationErrorescaping discovery, andKeyError: 'package-name'), while the third passes and must keep passing: it asserts aSchemaErrorstill propagates, and it fails against a broadexcept Exception, which is what pins the narrow catch.