Skip to content

Commit 739c807

Browse files
authored
Validate provider metadata list entries instead of ignoring them (#71104)
* Validate provider metadata list entries instead of ignoring them The items blocks for queues, plugins and task-decorators listed their field names directly under items, where they are not JSON Schema keywords, so the blocks were inert and any shape passed. A provider author following what those blocks appeared to document — a dict for queues, or a path key for a decorator — got no error and was quietly dropped by the consumers instead. Pinning each section to the shape the provider.yaml files and generated payloads actually use turns that into a failure at authoring time. The custom-provider howto named the same nonexistent path field. Raised in review of #70190. * Keep runtime provider metadata validation permissive The runtime schema is documented as deliberately looser than the development one, and its validate() call is unwrapped in provider discovery, so a single installed provider emitting an outdated entry shape would abort discovery for every provider in that process instead of costing just that entry a logged warning. The structural descriptions stay behind so the schema no longer documents a shape it never actually enforced. * Reject unknown keys in provider.yaml decorator and plugin entries Requiring the right keys does not stop a leftover one sitting beside them, so a stale `path:` next to a correct `class-name:` still validated — exactly the confusion this branch set out to remove. Every sibling item block in this authoring schema already closes itself off this way.
1 parent 6a0c3a6 commit 739c807

3 files changed

Lines changed: 54 additions & 39 deletions

File tree

airflow-core/src/airflow/provider.yaml.schema.json

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -565,12 +565,22 @@
565565
"type": "array",
566566
"description": "Decorators to use with the TaskFlow API. Can be accessed by users via '@task.<name>'",
567567
"items": {
568-
"name": {
569-
"type": "string"
568+
"type": "object",
569+
"properties": {
570+
"name": {
571+
"description": "Name the decorator is exposed under, following '@task.'",
572+
"type": "string"
573+
},
574+
"class-name": {
575+
"description": "Class name that implements the decorator",
576+
"type": "string"
577+
}
570578
},
571-
"path": {
572-
"type": "string"
573-
}
579+
"additionalProperties": false,
580+
"required": [
581+
"name",
582+
"class-name"
583+
]
574584
}
575585
},
576586
"secrets-backends": {
@@ -688,24 +698,29 @@
688698
"type": "array",
689699
"description": "Plugins exposed by the provider",
690700
"items": {
691-
"name": {
692-
"type": "string"
701+
"type": "object",
702+
"properties": {
703+
"name": {
704+
"description": "Name of the plugin",
705+
"type": "string"
706+
},
707+
"plugin-class": {
708+
"description": "Class name that implements the plugin",
709+
"type": "string"
710+
}
693711
},
694-
"plugin-class": {
695-
"type": "string"
696-
}
712+
"additionalProperties": false,
713+
"required": [
714+
"name",
715+
"plugin-class"
716+
]
697717
}
698718
},
699719
"queues": {
700720
"type": "array",
701-
"description": "Message Queues exposed by the provider",
721+
"description": "Message queue provider class names",
702722
"items": {
703-
"name": {
704-
"type": "string"
705-
},
706-
"message-queue-class": {
707-
"type": "string"
708-
}
723+
"type": "string"
709724
}
710725
},
711726
"source-date-epoch": {

airflow-core/src/airflow/provider_info.schema.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -432,39 +432,39 @@
432432
"type": "array",
433433
"description": "Apply custom decorators to the TaskFlow API. Can be accessed by users via '@task.<name>'",
434434
"items": {
435-
"name": {
436-
"type": "string"
437-
},
438-
"path": {
439-
"type": "string"
435+
"type": "object",
436+
"properties": {
437+
"name": {
438+
"description": "Name the decorator is exposed under, following '@task.'",
439+
"type": "string"
440+
},
441+
"class-name": {
442+
"description": "Class name that implements the decorator",
443+
"type": "string"
444+
}
440445
}
441446
}
442447
},
443448
"plugins": {
444449
"type": "array",
445450
"description": "Plugins provided by the provider",
446451
"items": {
447-
"name": {
448-
"type": "string",
449-
"description": "Name of the plugin"
450-
},
451-
"plugin-class": {
452-
"type": "string",
453-
"description": "Class to instantiate the plugin"
452+
"type": "object",
453+
"properties": {
454+
"name": {
455+
"type": "string",
456+
"description": "Name of the plugin"
457+
},
458+
"plugin-class": {
459+
"type": "string",
460+
"description": "Class to instantiate the plugin"
461+
}
454462
}
455463
}
456464
},
457465
"queues": {
458466
"type": "array",
459-
"description": "Message Queues exposed by the provider",
460-
"items": {
461-
"name": {
462-
"type": "string"
463-
},
464-
"message-queue-class": {
465-
"type": "string"
466-
}
467-
}
467+
"description": "Message queue provider class names"
468468
}
469469
},
470470
"definitions": {

providers-summary-docs/howto/create-custom-providers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Exposing customized functionality to the Airflow's core:
114114
* ``sensors`` - this field should contain the list of all the sensor class names that the
115115
provider provides. See :doc:`apache-airflow:core-concepts/sensors` for description of the sensors.
116116

117-
* ``task-decorators`` - this field should contain the list of dictionaries of name/path where the decorators
117+
* ``task-decorators`` - this field should contain the list of dictionaries of name/class-name where the decorators
118118
are available. See :doc:`apache-airflow:howto/create-custom-decorator` for description of how to add
119119
custom decorators.
120120

0 commit comments

Comments
 (0)