Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
duhizjame opened this issue Dec 6, 2023 · 3 comments

Comments

@duhizjame
Copy link

duhizjame commented Dec 6, 2023

  • 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.

@Chaffelson
Copy link
Owner

Chaffelson commented Dec 6, 2023

Hi @duhizjame this comes up occasionally string literals in the NiFi swagger spec - it was never originally written to be used to generate a client like this, so we sometimes run into these conversion issues.

The model code is templated here
I note in the swagger def that it is canonically CAPS.
I have a memory that this should not be all caps from a previous bug like this, we could check in with the NiFi dev community for an opinion?

Edit: Posted on Slack

@duhizjame
Copy link
Author

Thanks for the fast response! @Chaffelson
I joined the slack channel, so I'll monitor if there is any progress as well. Until then, monkey patching will do the job 😄

@Hexoplon
Copy link
Contributor

Hexoplon commented Dec 8, 2023

There is an existing NiFi issue on this: NIFI-12302

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants