Page MenuHomeVyOS Platform

Tunnel argument to 'reset_peer' in ipsec.py should have type hint Optional
Closed, ResolvedPublic

Description

The function 'reset_peer' in op-mode ipsec.py allows the case of tunnel=None, returning all tunnels for the peer in that case. Consequently, the type hint should be Optional[str], so that the opmode module, respectively, the API schema generation, will translate the argument to have default value None.

Note that the type hint Optional does not implicitly have anything to do with default values; it is a simply a shorthand for type Union[..., None], so that type None is allowed by type checking. However, the technique of 'introspection+type_hints' used by the opmode module, respectively, the schema generation functions of the HTTP-API, explicitly translates the type hint Optional to provide the default argument '=None'. This allows args of type Optional to be not required for the CLI, and nullable by the API.

Details

Difficulty level
Unknown (require assessment)
Version
vyos-1.4
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible
Issue type
Improvement (missing useful functionality)

Event Timeline

jestabro triaged this task as Normal priority.Fri, Nov 18, 10:19 PM
jestabro created this task.
jestabro created this object in space S1 VyOS Public.
jestabro moved this task from Need Triage to Finished on the VyOS 1.4 Sagitta board.