hyperglass icon indicating copy to clipboard operation
hyperglass copied to clipboard

Incorrect validation of HTTP options in device config

Open Computroniks opened this issue 10 months ago • 0 comments

Deployment Type

Other (please explain)

Development environment

Version

v2.0.4

Steps to Reproduce

While I was working on #329 I noticed an issue with the following lines.

https://github.com/thatmattlove/hyperglass/blob/15491f904b1522b639b3dc2a4b051e37b4c87bb7/hyperglass/models/config/devices.py#L212-L232

The intention I assume is to raise an error when no HTTP config is provided when the http platform is used. However, http is never None as it is set here: https://github.com/thatmattlove/hyperglass/blob/15491f904b1522b639b3dc2a4b051e37b4c87bb7/hyperglass/models/config/devices.py#L65

This allows the HTTP platform to be selected with no HTTP config present.

I can create a PR to fix (I assume it should just be a case of changing L65 as follows but I want to check this isn't some how intentional.


class Device(HyperglassModelWithId, extra="allow"):
    """Validation model for per-router config in devices.yaml."""

    id: str
    name: str
    description: t.Optional[str] = None
    avatar: t.Optional[FilePath] = None
    address: t.Union[IPv4Address, IPv6Address, str]
    group: t.Optional[str] = None
    credential: Credential
    proxy: t.Optional[Proxy] = None
    display_name: t.Optional[str] = None
    port: int = 22
-   http: HttpConfiguration = HttpConfiguration()
+   http: t.Optional[HttpConfiguration] = None
    platform: str
    structured_output: t.Optional[bool] = None

Expected Behavior

Error thrown.

Observed Behavior

No error thrown.

Configuration


Devices

devices:
  - name: UKSE1 (London)
    address: 127.0.0.1
    credential:
      username: test
      password: test
    platform: http
    attrs:
      source4: 127.0.0.1
      source6: 2001:db8::1

Logs


Computroniks avatar Jun 04 '25 12:06 Computroniks