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

Error in validating the path for custom_template field while creating the Event channel #71

Open
sachin-apa opened this issue Mar 12, 2024 · 2 comments

Comments

@sachin-apa
Copy link

While creating a event channel, when a path is specified for custom template field it fails with an error as regex is not matching.

Run the script with a below code where custom_template field is given an input as "/ifs/data"

parameters = isilon_sdk.v9_5_0.EventChannelParameters(
    address="my.email.com",
    custom_template="/ifs/data"
)

event_channel = isilon_sdk.v9_5_0.EventChannelCreateParams(
    enabled=enabled,
    name=name,
    type=type,
    allowed_nodes=allowed_nodes,
    excluded_nodes=excluded_nodes,
    parameters=parameters
)

try:
      api_response = api_instance.create_event_channel(event_channel)
      pprint(api_response)
except ApiException as e:
      print("Exception when calling EventApi->create_event_channel: %s\n" % e)

Actual
Fails with an error as below

Traceback (most recent call last):
  File "/home/sachin/collections/tryout/powerscale_scripts/event_channel.py", line 159, in <module>
    parameters = isilon_sdk.v9_5_0.EventChannelParameters(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sachin/.local/lib/python3.11/site-packages/isilon_sdk/v9_5_0/models/event_channel_parameters.py", line 87, in __init__
    self.custom_template = custom_template
    ^^^^^^^^^^^^^^^^^^^^
  File "/home/sachin/.local/lib/python3.11/site-packages/isilon_sdk/v9_5_0/models/event_channel_parameters.py", line 209, in custom_template
    raise ValueError("Invalid value for `custom_template`, must be a follow pattern or equal to `/^((\/[^\/[:cntrl:]]+)(\/?))*$/`")  # noqa: E501
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Invalid value for `custom_template`, must be a follow pattern or equal to `/^((\/[^\/[:cntrl:]]+)(\/?))*$/`

Expected

Create event channel as the input "/ifs/data/" is a correct input for the field "custom_template".

@sachin-apa
Copy link
Author

sachin-apa commented Mar 12, 2024

The Issue is because of the regex used '^((\/[^\/[:cntrl:]]+)(\/?))*$'
Python regex library is not recognising [:cntrl:] as control parameters, but is just considering as a regular text matching c t r l and hence the SDK is throwing error.

>>> import re
>>> re.search('^((\/[^\/[:cntrl:]]+)(\/?))*$', "/ifs/data" )
>>> re.search('^((\/[^\/[:cntrl:]]+)(\/?))*$', "/]]]]]]/" )
<re.Match object; span=(0, 8), match='/]]]]]]/'>

Alternative to [:cntrl:] in python is to use [\x00-\x1F\x7F] so the regular expression would be ^((\/[^\x00-\x1F\x7F]+)(\/?))*$

>>> re.search('^((\/[^\x00-\x1F\x7F]+)(\/?))*$', "/]]]]]]/" )
<re.Match object; span=(0, 8), match='/]]]]]]/'>
>>> re.search('^((\/[^\x00-\x1F\x7F]+)(\/?))*$', "/ifs/data" )
<re.Match object; span=(0, 9), match='/ifs/data'>

@Bhavneet-Sharma
Copy link

I encountered the same error while attempting to retrieve the details of the ADS provider using this method: Isilon SDK v0.3.0.1 AuthApi. The call fails with the following error:

ValueError: Invalid value for home_directory_template, must follow a pattern or be equal to /^((\/[^\/[:cntrl:]]+)(\/?))*$/.

However, this method works in SDK version 9.1, as referenced here.

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

2 participants