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

[202205] Fix exception in adding mirror_session when gre_type is absent #2476

Merged
merged 1 commit into from
Nov 4, 2022

Conversation

bingwang-ms
Copy link
Contributor

What I did

This PR is a duplication of https://github.com/sonic-net/sonic-utilities/pull/2458/files.
This PR is to fix the exception in adding mirror session when gre_type is absent.

~$ sudo config mirror_session add session_1 25.25.25.25 10.1.1.1 8 100
Traceback (most recent call last):
  File "/usr/local/bin/config", line 8, in <module>
    sys.exit(config())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1135, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 641, in make_context
    self.parse_args(ctx, args)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 940, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1476, in handle_parse_result
    value = invoke_param_callback(
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 96, in invoke_param_callback
    return callback(ctx, param, value)
  File "/usr/local/lib/python3.9/dist-packages/config/main.py", line 1069, in validate_gre_type
    if value.lower().startswith('0x'):
AttributeError: 'NoneType' object has no attribute 'lower'

How I did it

Add a check in validate_gre_type. If gre_type is absent, return None directly.

How to verify it

Verified by UT and running on a testbed.

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

@bingwang-ms bingwang-ms changed the title [2022] Fix exception in adding mirror_session when gre_type is absent [202205] Fix exception in adding mirror_session when gre_type is absent Nov 3, 2022
@lolyu lolyu merged commit 9d921a7 into sonic-net:202205 Nov 4, 2022
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

Successfully merging this pull request may close these issues.

2 participants