Skip to content

BundleTypeValues in ExtensionBundle are not matched by value, but by the Enum name #341

Closed
@duhizjame

Description

@duhizjame
  • Nipyapi version: 0.19
  • NiFi version: 1.19(but applicable to all versions)
  • NiFi-Registry version: 1.19
  • Python version: 3.11
  • Operating System: MacOS

Description

Right now the call:

bundles = nipyapi.registry.BundlesApi().get_bundles()

is throwing an exception:

  File "/Users/aleksandarmilosevic/Desktop/invoke.http/venv/lib/python3.11/site-packages/nipyapi/registry/models/extension_bundle.py", line 382, in bundle_type
    raise ValueError(
ValueError: Invalid value for `bundle_type` (nifi-nar), must be one of ['NIFI_NAR', 'MINIFI_CPP']

What I Did

This is the actual definition in the nifi-registry-core:

public class BundleTypeValues {

    public static final String NIFI_NAR_VALUE = "nifi-nar";
    public static final String MINIFI_CPP_VALUE = "minifi-cpp";

    public static final String ALL_VALUES = NIFI_NAR_VALUE + ", " + MINIFI_CPP_VALUE;
}

Changing the extension bundle bundle_type solves the issue:

    @bundle_type.setter
    def bundle_type(self, bundle_type):
        """
        Sets the bundle_type of this ExtensionBundle.
        The type of the extension bundle

        :param bundle_type: The bundle_type of this ExtensionBundle.
        :type: str
        """
        if bundle_type is None:
            raise ValueError("Invalid value for `bundle_type`, must not be `None`")
        # was allowed_values = ["NIFI_NAR", "MINIFI_CPP"]
        allowed_values = ["nifi-nar", "minifi-cpp"]
        if bundle_type not in allowed_values:
            raise ValueError(
                "Invalid value for `bundle_type` ({0}), must be one of {1}"
                .format(bundle_type, allowed_values)
            )

        self._bundle_type = bundle_type

Urgency

Not urgent, but a good fix for a CI/CD that my I am implementing.
I can open a PR to handle this if needed, so far I was fine with monkey patching
Although the documentation on the NiFi registry API is a bit misguiding as well, there is no mention of the actual values for the enum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions