Comment 1 for bug 2041679

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to distcloud (master)

Reviewed: https://review.opendev.org/c/starlingx/distcloud/+/899490
Committed: https://opendev.org/starlingx/distcloud/commit/a46055a2efd9a7acb1e37368b551979ea3d650f1
Submitter: "Zuul (22348)"
Branch: master

commit a46055a2efd9a7acb1e37368b551979ea3d650f1
Author: srana <email address hidden>
Date: Fri Oct 27 11:40:39 2023 -0400

    Fix: Error Handling for YAML Load

    Introduce yaml_safe_load, a util wrapper to invoke
    yaml.safe_load and correctly handle malformed YAML files.
    This wrapper catches exceptions thrown (e.g., incorrect syntax)
    while loading/parsing a yaml file. Currently, there's no error
    reported back to the user on such failures, rather an ambiguous
    python object string is reported and the user is unaware of the
    cause of failure. All calls for reading yaml files being uploaded
    by the user have been replaced with the wrapper for correct error
    reporting.

    Test:
      1. PASS: Ensure that the following error message is reported when
               a malformed file is passed to a command:
               "Error: Unable to load file contents.
               (problem on line: #)."
                - Add an entry in the bootstrap yaml file without a
                  space after the colon:
                    "key:val"
                - Run dcmanager subcloud add with the
                  malformed bootstrap file
                - Check the cmdline reported error
      2. PASS: Repeat test #1 with common YAML issues, for example:
                - Incorrect indentation
                - Missing new line between entries
      3. PASS: Repeat test #1 with an empty file. Ensure that the
               following error message is reported:
               "Error: Unable to load file contents.
               (empty file provided)."

    Closes-Bug: 2041679

    Change-Id: I33210a45038d6d4e98b69809ffa8d2d431b43190
    Signed-off-by: Salman Rana <email address hidden>