atheendre130505 opened a new pull request, #37589:
URL: https://github.com/apache/beam/pull/37589
Fix json_utils.py object validation logic and mangled error messages
This PR addresses critical bugs in Apache Beam's YAML JSON utility that led
to silent validation passes or internal crashes when handling object-type
schemas.
Changes: Corrected Object Validation: Fixed logic in _validate_compatible
where weak_schema == 'object' was always false (comparing dict to string). It
now correctly checks weak_schema['type'] == 'object'.
Fixed Iteration Crash: Added .items() to dictionary iteration in
_validate_compatible to prevent ValueError: not enough values to unpack.
Restored F-Strings: Added missing f prefixes to multiple ValueError and
TypeError calls, ensuring error messages like Expected object type, got
{json_type} correctly interpolate variables.
Fixed Formatting Bug: Corrected a ValueError in _validate_compatible
where a boolean expression was passed to a format string expecting the type
names.
Added Regression Tests: Updated json_utils_test.py with tests verifying that
incompatible object schemas are caught and that error messages are properly
formatted.
unit tests implemented.
fixes #37576
--
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]