udsy19 opened a new pull request, #74930:
URL: https://github.com/apache/airflow/pull/74930
## Why
`GcpBodyFieldValidator.validate()` emits a spurious warning for **valid,
applicable** body fields.
The post-validation check that reports body fields *"is in the body, but is
not specified in the validation specification"* builds its set of known field
names with an inverted `api_version` filter:
```python
all_field_names = {
spec["name"]
for spec in self._validation_specs
if spec.get("type") != "union" and spec.get("api_version") !=
self._api_version
}
```
A non-union field whose spec `api_version` **equals** the validator's
`api_version` is a valid, applicable field — `_validate_field` only *skips* a
field when its `api_version` **differs** (`if required_api_version and
required_api_version != self._api_version: return False`). The `!=` comparison
excluded exactly those applicable fields from `all_field_names`, so a correct,
spec-defined, successfully validated field present in the body produced the
spurious warning. The same inverted filter was applied to union-nested field
names.
Users of GCP operators that rely on API-version-tagged body fields see
misleading warnings for perfectly valid request fields.
## What
Include a field whenever it has no `api_version` or its `api_version`
matches the validator's — mirroring `_validate_field`'s own applicability rule
— for both the top-level and union-nested comprehensions. The common
no-`api_version` case is unchanged.
## Tests
Adds two regression tests in
`providers/google/tests/unit/google/cloud/utils/test_field_validator.py` using
`caplog` in the existing style. Verified fail-on-revert: with the source
reverted both tests fail (the valid field warns); with the fix they pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]